Skip to content

Commit

Permalink
Merge branch 'lacmuch-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mrg2001 committed Dec 28, 2016
2 parents c3081e4 + bbf7ba3 commit db72e5f
Show file tree
Hide file tree
Showing 13 changed files with 265 additions and 64 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules/
*.ipr
*.iws
/npm-debug.log
.DAV
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ module.exports = function (grunt) {
concat: {
w2ui: {
options: {
banner: w2ui
banner: w2ui,
sourceMap: true
},
src: [
'src/w2utils.js',
Expand Down
32 changes: 25 additions & 7 deletions dist/w2ui-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -2083,7 +2083,8 @@ w2utils.event = {
onHide : null, // callBack when hidden
hideOnKeyPress : true, // hide tag if key pressed
hideOnBlur : false, // hide tag on blur
hideOnClick : false // hide tag on document click
hideOnClick : false, // hide tag on document click
hideOnChange : true
}, options);
if (options.name != null && options.id == null) options.id = options.name;

Expand All @@ -2102,6 +2103,9 @@ w2utils.event = {
// main object
var tag;
var origID = (options.id ? options.id : el.id);
if (origID == '') { // search for an id
origID = $(el).find('input').attr('id');
}
var tmpID = w2utils.escapeId(origID);
if ($(this).data('w2tag') != null) {
tag = $(this).data('w2tag');
Expand Down Expand Up @@ -2169,6 +2173,13 @@ w2utils.event = {
if (tag.options.hideOnKeyPress) {
$(tag.attachedTo).on('keypress.w2tag', tag.hide);
}
if (options.hideOnChange) {
if (el.nodeName == 'INPUT') {
$(el).on('change.w2tag', tag.hide);
} else {
$(el).find('input').on('change.w2tag', tag.hide);
}
}
if (tag.options.hideOnBlur) {
$(tag.attachedTo).on('blur.w2tag', tag.hide);
}
Expand Down Expand Up @@ -5653,15 +5664,21 @@ w2utils.event = {
return;
}
if (options.maxSize !== 0 && size + newItem.size > options.maxSize) {
err = 'Maximum total size is '+ w2utils.formatSize(options.maxSize);
if (options.silent === false) $(obj.el).w2tag(err);
console.log('ERROR: '+ err);
err = w2utils.lang('Maximum total size is') + ' ' + w2utils.formatSize(options.maxSize);
if (options.silent === false) {
$(obj.el).w2tag(err);
} else {
console.log('ERROR: '+ err);
}
return;
}
if (options.max !== 0 && cnt >= options.max) {
err = 'Maximum number of files is '+ options.max;
if (options.silent === false) $(obj.el).w2tag(err);
console.log('ERROR: '+ err);
err = w2utils.lang('Maximum number of files is') + ' '+ options.max;
if (options.silent === false) {
$(obj.el).w2tag(err);
} else {
console.log('ERROR: '+ err);
}
return;
}
selected.push(newItem);
Expand All @@ -5684,6 +5701,7 @@ w2utils.event = {
} else {
obj.refresh();
$(obj.el).trigger('change');
obj.trigger($.extend(edata, { phase: 'after' }));
}
},

Expand Down
6 changes: 3 additions & 3 deletions dist/w2ui-fields.min.js

Large diffs are not rendered by default.

99 changes: 79 additions & 20 deletions dist/w2ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2083,7 +2083,8 @@ w2utils.event = {
onHide : null, // callBack when hidden
hideOnKeyPress : true, // hide tag if key pressed
hideOnBlur : false, // hide tag on blur
hideOnClick : false // hide tag on document click
hideOnClick : false, // hide tag on document click
hideOnChange : true
}, options);
if (options.name != null && options.id == null) options.id = options.name;

Expand All @@ -2102,6 +2103,9 @@ w2utils.event = {
// main object
var tag;
var origID = (options.id ? options.id : el.id);
if (origID == '') { // search for an id
origID = $(el).find('input').attr('id');
}
var tmpID = w2utils.escapeId(origID);
if ($(this).data('w2tag') != null) {
tag = $(this).data('w2tag');
Expand Down Expand Up @@ -2169,6 +2173,13 @@ w2utils.event = {
if (tag.options.hideOnKeyPress) {
$(tag.attachedTo).on('keypress.w2tag', tag.hide);
}
if (options.hideOnChange) {
if (el.nodeName == 'INPUT') {
$(el).on('change.w2tag', tag.hide);
} else {
$(el).find('input').on('change.w2tag', tag.hide);
}
}
if (tag.options.hideOnBlur) {
$(tag.attachedTo).on('blur.w2tag', tag.hide);
}
Expand Down Expand Up @@ -10388,9 +10399,15 @@ w2utils.event = {
if (record && record.w2ui && record.w2ui.changes && record.w2ui.changes[col.field] != null) {
data = record.w2ui.changes[col.field];
}
if ($.isPlainObject(data) && col.editable) {
if (data.text != null) data = data.text;
if (data.id != null) data = data.id;
if ($.isPlainObject(data) /*&& col.editable*/) { //It can be an object btw
if (col.options && col.options.items) {
val=col.options.items.find(function(item){ return item.id==data.id});
if (val) data=val.text;
else data=data.id;
} else {
if (data.text != null) data = data.text;
if (data.id != null) data = data.id;
}
}
if (data == null) data = '';
return data;
Expand Down Expand Up @@ -17774,15 +17791,21 @@ var w2prompt = function (label, title, callBack) {
return;
}
if (options.maxSize !== 0 && size + newItem.size > options.maxSize) {
err = 'Maximum total size is '+ w2utils.formatSize(options.maxSize);
if (options.silent === false) $(obj.el).w2tag(err);
console.log('ERROR: '+ err);
err = w2utils.lang('Maximum total size is') + ' ' + w2utils.formatSize(options.maxSize);
if (options.silent === false) {
$(obj.el).w2tag(err);
} else {
console.log('ERROR: '+ err);
}
return;
}
if (options.max !== 0 && cnt >= options.max) {
err = 'Maximum number of files is '+ options.max;
if (options.silent === false) $(obj.el).w2tag(err);
console.log('ERROR: '+ err);
err = w2utils.lang('Maximum number of files is') + ' '+ options.max;
if (options.silent === false) {
$(obj.el).w2tag(err);
} else {
console.log('ERROR: '+ err);
}
return;
}
selected.push(newItem);
Expand All @@ -17805,6 +17828,7 @@ var w2prompt = function (label, title, callBack) {
} else {
obj.refresh();
$(obj.el).trigger('change');
obj.trigger($.extend(edata, { phase: 'after' }));
}
},

Expand Down Expand Up @@ -18088,6 +18112,9 @@ var w2prompt = function (label, title, callBack) {
this.tabs = {}; // if not empty, then it is tabs object
this.style = '';
this.focus = 0; // focus first or other element
// When w2utils.settings.dataType is JSON, then we can convert the save request to multipart/form-data. So we can upload large files with the form
// The original body is JSON.stringified to __body
this.multipart = false;

// internal
this.isGenerated = false;
Expand Down Expand Up @@ -18424,19 +18451,20 @@ var w2prompt = function (label, title, callBack) {
if (showErrors) {
for (var e = 0; e < edata.errors.length; e++) {
var err = edata.errors[e];
var opt = $.extend({ "class": 'w2ui-error' }, err.options);
if (err.field == null) continue;
if (err.field.type == 'radio') { // for radio and checkboxes
$($(err.field.el).parents('div')[0]).w2tag(err.error, { "class": 'w2ui-error' });
$($(err.field.el).parents('div')[0]).w2tag(err.error, opt);
} else if (['enum', 'file'].indexOf(err.field.type) != -1) {
(function (err) {
setTimeout(function () {
var fld = $(err.field.el).data('w2field').helpers.multi;
$(err.field.el).w2tag(err.error);
$(err.field.el).w2tag(err.error,err.options);
$(fld).addClass('w2ui-error');
}, 1);
})(err);
} else {
$(err.field.el).w2tag(err.error, { "class": 'w2ui-error' });
$(err.field.el).w2tag(err.error, opt);
}
this.goto(errors[0].field.page);
}
Expand Down Expand Up @@ -18638,13 +18666,14 @@ var w2prompt = function (label, title, callBack) {
$.extend(params, obj.postData);
$.extend(params, postData);
// clear up files
obj.fields.forEach(function (item) {
if (item.type == 'file' && Array.isArray(obj.record[item.field])) {
obj.record[item.field].forEach(function (fitem) {
delete fitem.file;
if (!obj.multipart)
obj.fields.forEach(function (item) {
if (item.type == 'file' && Array.isArray(obj.record[item.field])) {
obj.record[item.field].forEach(function (fitem) {
delete fitem.file;
});
}
});
}
});
params.record = $.extend(true, {}, obj.record);
// event before
var edata = obj.trigger({ phase: 'before', type: 'submit', target: obj.name, url: obj.url, postData: params, httpHeaders: obj.httpHeaders });
Expand Down Expand Up @@ -18704,8 +18733,38 @@ var w2prompt = function (label, title, callBack) {
break;
case 'JSON':
ajaxOptions.type = 'POST';
ajaxOptions.data = JSON.stringify(ajaxOptions.data);
ajaxOptions.contentType = 'application/json';
if (!obj.multipart) {
ajaxOptions.data = JSON.stringify(ajaxOptions.data);
} else {
function apend(fd, dob, fob, p){
if (p == null) p = '';
function isObj(dob, fob, p){
if (typeof dob == 'object' && dob instanceof File) fd.append(p, dob);
if (typeof dob == "object"){
if (!!dob && dob.constructor === Array) {
for (var i = 0; i < dob.length; i++) {
var aux_fob = !!fob ? fob[i] : fob;
isObj(dob[i], aux_fob, p+'['+i+']');
}
} else {
apend(fd, dob, fob, p);
}
}
}
for(var prop in dob){
var aux_p = p == '' ? prop : '${p}[${prop}]';
var aux_fob = !!fob ? fob[prop] : fob;
isObj(dob[prop], aux_fob, aux_p);
}
}
var fdata = new FormData();
fdata.append('__body', JSON.stringify(ajaxOptions.data));
apend(fdata,ajaxOptions.data)
ajaxOptions.data = fdata;
ajaxOptions.contentType = false;
ajaxOptions.processData = false;
}
break;
}
if (this.method) ajaxOptions.type = this.method;
Expand Down
1 change: 1 addition & 0 deletions dist/w2ui.js.map

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions dist/w2ui.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-concat": "~1.0.1",
"grunt-contrib-less": "~0.9.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-shell": "~0.6.4",
Expand Down
62 changes: 62 additions & 0 deletions src/locale/hu-hu.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"dateFormat" : "yyyy.mm.dd",
"timeFormat" : "h24",
"currency" : "^[\\$]?[-+]?[0-9]*[\\.]?[0-9]+$",
"currencyPrefix" : "",
"currencySuffix" : "Ft",
"groupSymbol" : ",",
"decimalSymbol" : ".",
"float" : "^[-]?[0-9]*[\\.]?[0-9]+$",
"shortmonths" : ["Jan", "Feb", "Már", "Ápr", "Máj", "Jún", "Júl", "Aug", "Szep", "Okt", "Nov", "Dec"],
"fullmonths" : ["Január", "Február", "Március", "Április", "Május", "Június", "Július", "Augusztus", "Szeptember", "Október", "November", "December"],
"shortdays" : ["H", "K", "SZE", "CS", "P", "SZO","V"],
"fulldays" : ["Hétfő", "Kedd", "Szerda", "Csütörtök", "Péntek", "Szombat", "Vasárnap"],
"phrases" : {
"Required field": "A mező kitöltése kötelező",
"Server Response": "Szerver válasza",
"Reload data in the list": "Lista frissítése",
"Show/hide columns": "Oszlopok elrejtése/megjelenítése",
"All Fields": "Összes mező",
"Save Grid State": "Táblázat állapotának mentése",
"Restore Default State": "Táblázat alapállapotának visszaállítása",
"Attach files by dragging and dropping or Click to Select": "Ide fájlt kell feltöltenie. Hozzáadásához húzza ide, vagy klikkeljen a mezőre!",
"Skip": "Kihagy",
"Line #": "Sorszám #",
"Record ID": "Belső azonosító",
"Records": "bekegyzést",
"Modified": "Módosítva",
"Type": "Típus",
"Name": "Név",
"Size": "Méret",
"of": "ebből",
"sec": "mp",
"Refreshing...": "Adatok betöltése...",
"Edit": "Szerkesztés",
"Edit selected record": "Kijelölt bejegyzés szerkesztése",
"Notification": "Értesítés",
"Add new record": "Új bejegyzés hozzáadása",
"Add New": "Új hozzáadása",
"Delete Confirmation": "Törlése megerősítése",
"Are you sure you want to delete selected records?": "Biztosan törli a kijelölt bejegyzés(eke)t?",
"Delete": "Törlés",
"Delete selected records": "Kijelölt bejegyzés törlése",
"Yes": "Igen",
"No": "Nem",
"AJAX error. See console for more details.": "Kommunikációs hiba. Kérjük jelezze az oldal üzemeltetőjének!",
"Confirmation": "Megerősítés",
"No matches": "Nincs találat",
"Maximum total size is": "A csatolmányok maximális összmérete",
"Maximum number of files is": "A csatolmányok maximális száma",
"Search": "Keresés",
"Reset": "Alaphelyzet",
"is": "egyenlő",
"between": "között",
"less than": "kevesebb mint",
"more than": "több mint",
"Multiple Fields": "Több mező",
"contains": "tartalmaz",
"begins": "kezdődik",
"ends": "végződik",
"Open Search Fields": "Kereső megnyitása"
}
}
19 changes: 13 additions & 6 deletions src/w2fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -2410,15 +2410,21 @@
return;
}
if (options.maxSize !== 0 && size + newItem.size > options.maxSize) {
err = 'Maximum total size is '+ w2utils.formatSize(options.maxSize);
if (options.silent === false) $(obj.el).w2tag(err);
console.log('ERROR: '+ err);
err = w2utils.lang('Maximum total size is') + ' ' + w2utils.formatSize(options.maxSize);
if (options.silent === false) {
$(obj.el).w2tag(err);
} else {
console.log('ERROR: '+ err);
}
return;
}
if (options.max !== 0 && cnt >= options.max) {
err = 'Maximum number of files is '+ options.max;
if (options.silent === false) $(obj.el).w2tag(err);
console.log('ERROR: '+ err);
err = w2utils.lang('Maximum number of files is') + ' '+ options.max;
if (options.silent === false) {
$(obj.el).w2tag(err);
} else {
console.log('ERROR: '+ err);
}
return;
}
selected.push(newItem);
Expand All @@ -2441,6 +2447,7 @@
} else {
obj.refresh();
$(obj.el).trigger('change');
obj.trigger($.extend(edata, { phase: 'after' }));
}
},

Expand Down
Loading

0 comments on commit db72e5f

Please sign in to comment.