Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

evolutility

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

evolutility - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

demo/contact.html

2

bower.json
{
"name": "evolutility",
"version": "0.0.1",
"version": "0.0.2",
"dependencies": {

@@ -5,0 +5,0 @@ "jquery": "2.0.3",

@@ -1,6 +0,6 @@

/* evolutility 0.0.1 */
/* evolutility 0.0.2 */
/* (c) 2013 Olivier Giulieri */
/* (c) 2014 Olivier Giulieri */
var Evol=Evol||{};Evol.UI={version:"0.0.1",html:{trTableEnd:"</tr></table>",TdTrTableEnd:"</td></tr></table>",clearer:'<div class="clearfix"></div>',emptyOption:'<option value=""></option>'},icons:{customize:function(a,b){return['<i class="glyphicon glyphicon-wrench" data-id="',a,'" data-type="',b,'"></i>'].join("")}},styles:{success:"success",info:"info",warning:"warning",danger:"danger"},html_more:function(a){return['<a href="javascript:void(0)" class="evol-more">',a,"</a>"].join("")},fieldLabel:function(a,b){return['<div class="evol-field-label"><label for="',a,'">',b,"</label></div>"].join("")},fieldLabelSpan:function(a,b){return['<span class="evol-field-label"><label for="',a,'">',b,"</label></span>"].join("")},link:function(a,b,c){return['<a class="Field" href="',c,'" id="',a,'">',b,"</a>"].join("")},linkEmail:function(a,b,c){return EvoUI.link(a,b,c?"mailto:"+c:"")},inputText:function(a,b,c){var d=['<input class="form-control" type="text" id="',a,'" value="',b];return c&&(_.each(["min","max","maxlength","max-width","min-width","placeholder"],function(a){"undefined"!==c[a]&&d.push('" ',a,'="',c[a])}),_.each(["readonly"],function(a){var b=c[a];(b||"1"==b)&&d.push('" ',a,'="',a)})),d.push('" class="Field">'),d.join("")},inputTextInt:function(a,b){return['<input class="form-control" type="number" id="',a,'" value="',b,'" class="Field" maxlength="12">'].join("")},inputTextM:function(a,b,c,d){return['<textarea name="',a,'" id="',a,'" class="Field form-control"" rows="',d,c>0?'" onKeyUp="EvoVal.checkMaxLen(this,'+c+")":"",'">',b,"</textarea>"].join("")},inputTextMJSON:function(a,b,c){return['<textarea rows="',c,'" class="evol-json">',_.escape(JSON.stringify(b,null," ")),"</textarea>"].join("")},inputAny:function(a,b,c){return['<input type="',a,'" id="',b,'" value="',c,'" class="Field form-control" size="15">'].join("")},inputDate:function(a,b){return EvoUI.inputAny("date",a,b)},inputDateTime:function(a,b){return EvoUI.inputAny("datetime-local",a,b)},inputTime:function(a,b){return EvoUI.inputAny("time",a,b)},inputColor:function(a,b){return['<input type="color" id="',a,'" value="',b,'" size="15">'].join("")},inputCheckbox:function(a,b){var c=['<input type="checkbox" id="',a,'"'];return null!==b&&""!==b&&"0"!==b&&c.push(' checked="checked"'),c.push(' value="1">'),c.join("")},inputCheckboxLOV:function(a){var b=[];for(var c in a){var d=a[c];b.push('<input type="checkbox" id="',d.id,'" value="',d.id,'"/>','<label for="',d.id,'">',d.text,"</label> ")}return b.join("")},inputRadio:function(a,b,c,d,e){return['<label for="',e,'"><input id="',e,'" name="',a,'" type="radio" value="',b,d?'" checked="checked':"",'">',c,"</label>&nbsp;"].join("")},inputLOV:function(a,b,c,d){var e=['<select class="form-control Field" id="',a,'"><option value="',b,'" selected>',c,"</option>"];return _.each(d,function(a){e.push(EvoUI.inputOption(a.id,a.text))}),e.push("</select>"),e.join("")},inputHidden:function(a,b){return['<input type="hidden" name="',a,'" id="',a,'" value="',b,'"/>'].join("")},inputSelectBegin:function(a,b,c){var d=['<select id="',a,'" class="form-control ',b,'">'];return c&&d.push(Evol.UI.html.emptyOption),d.join("")},inputOption:function(a,b){return['<option value="',a,'">',b,"</option>"].join("")},inputOptions:function(a){var b=[];return _.each(a,function(a){b.push(EvoUI.inputOption(a.id,a.text))}),b.join("")},inputButton:function(a,b,c){return'<button type="button" id="'+a+'" class="btn'+(c?" "+c:"")+'">'+b+"</button>"},inputToggle:function(a){var b=['<div class="btn-group" data-toggle="buttons">'];return _.each(a,function(a){b.push('<label class="btn btn-info"><input type="radio" name="options" id="',a.id,'">',a.text,"</label>")}),b.push("</div>"),b.join("")},icon:function(a,b){return['<span class="',b?b+" ":"","glyphicon glyphicon-",a,'"></span>'].join("")},HTMLPanelLabel:function(a){return['<div class="panel-heading">',EvoUI.icon("chevron-up","evol-title-toggle"),'<h3 class="panel-title">',a,"</h3></div>"].join("")},HTMLEmptyPanel:function(a,b,c){return'<div class="'+b+" panel panel-"+c+'" data-id="'+a+'"></div>'},HTMLMsg:function(a,b,c,d){return['<div data-id="msg" class="alert alert-',c||"info",d?' alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>':'">',"<strong>",a,"</strong> ",b,"</div>"].join("")},formatDate:function(a){return a.getMonth()+1+"/"+(a.getDate()+1)+"/"+a.getFullYear()},formatTime:function(a){return a.getHours()+":"+a.getMinutes()},getOrCreate:function(a,b){var c=b.find("#"+a);return 0===c.length&&($('<div id="'+a+'"></div>'),(b||$(body)).append(c),c=b.find("#"+a)),c},insertCollection:function(a,b){0===a.length&&_.each(b,function(b){a.create(b)})},capFirstLetter:function(a){return a&&a.length>0?a.substring(0,1).toUpperCase()+a.substring(1):""},trim:function(a){return a?a.replace(/^\s+|\s+$/g,""):""},setVisible:function(a,b){b?a.show():a.hide()}},Evol.UI.Charts={URL:"http://chart.apis.google.com/chart",_HTML:function(a,b){return['<div class="evol-chart-holder panel panel-info"><label class="evol-chart-title">',a,'</label><img src="',b,'"><br></div>'].join("")},Pie:function(a,b,c){var d=[EvoUI.Charts.URL,"?chd=t:",b.join(","),"&amp;chl=",c.join("|"),"&amp;cht=p&amp;chds=0,20&amp;chs=360x200"].join("");return EvoUI.Charts._HTML(a,d)},Bars:function(a,b,c){var d=_.max(b),e=[EvoUI.Charts.URL,"?chbh=a&amp;chs=350x200&cht=bvg&chco=3a87ad,d9edf7&chds=0,",d,"&amp;chd=t:",b.join("|"),"&amp;chp=0.05&amp;chts=676767,10.5&amp;chdl=",c.join("|")].join("");return EvoUI.Charts._HTML(a,e)}};var Evol=Evol||{};Evol.Dico={fieldTypes:{text:"text",txtm:"textmultiline",bool:"boolean",dec:"decimal",integer:"integer",date:"date",time:"time",datetime:"datetime",pix:"image",lov:"lov",email:"email",url:"url",pwd:"password",color:"color",hidden:"hidden",rating:"rating",tag:"tag"},fields:function(a,b){function c(a){a&&a.elements&&a.elements.length>0?_.each(a.elements,function(a){"panel-list"!=a.type&&c(a)}):d.push(a)}var d=[];return c(a),_.isFunction(b)&&(d=_.filter(d,b)),d},isTypeDateOrTime:function(a){return a==a==EvoDico.fieldTypes.datetime||EvoDico.fieldTypes.date||a==EvoDico.fieldTypes.time},showDesigner:function(a,b,c){var d,e=$('<div class="evol-des-'+b+'"></div>');switch(b){case"field":d=dico_field_ui}return c.closest(".evol-fld").after(e),vw=new Evol.ViewOne({model:null,uiModel:d,defaultView:"edit",el:e,style:"panel-primary",button_addAnother:!1}),e.on("click","button#save,button#cancel",function(a){e.remove()}),this},showInfoBox:function(a,b){var c=this.$el.find(".evol-head-info");if(c.length)c.html(a);else{var d=['<div class="evol-head-info alert alert-',b,'">',EvoUI.iconClose(),a,"</div>"].join("");this.$el.prepend(d)}return this},bbComparator:function(a){return function(b){return b.get(a)}},bbComparatorText:function(a){return function(b,c){return(b.get(a)||"").localeCompare(c.get(a)||"")}}};var EvolLang={LOCALE:"EN",View:"View",Edit:"Edit",New:"New",NewItem:"New Item",NewUpload:"New Upload",NewSearch:"New Search",Selections:"Selections",Selection:"Selection",Export:"Export",SearchRes:"Search Result",Delete:"Delete",All:"All",DeleteEntity:"Delete this {0}?",Back2SearchResults:"Back to search results",validation:{intro:"You are not finished yet:",empty:'"{0}" must have a value.',email:'"{0}" must be a valid email.',integer:'"{0}" must only use numbers.',decimal:'"{0}" must be a valid decimal numbers.',date:'"{0}" must be a valid date, format must be "MM/DD/YYYY" like "12/24/2005".',datetime:'"{0}" must be a valid date/time, format must be "MM/DD/YYYY hh:mm am/pm" like "12/24/2005 10:30 am".',time:'"{0}" must be a valid date/time, format must be "hh:mm am/pm" like "10:30 am".',max:'"{0}" must be smaller or equal to {1}.',min:'"{0}" must be greater or equal to {1}.',reg:'"{0}" must match the regular expression pattern "{1}".'},"export":{ExportEntity:"Export this {0}",ExportHeader:"Header",ExportSeparator:"Separator",ExportFirstLine:"First line for field names",ExportFormat:"Export format",ExportFields:"Fields to include in the export",IDkey:"ID (Primary Key)",AllFields:"Show all fields",ExportFormats:"Comma separated (CSV, TXT, XLS...)-HTML-SQL Insert Statements (SQL)-Tab separated values (TXT)-XML-Javascript Object Notation (JSON)",xpXMLroot:"Element name",xpSQL:"SQL Options",xpSQLTable:"Table name",xpSQLTrans:"Inside transaction",xpSQLId:"Enable identity insert",DownloadEntity:"Download {0}"},Save:"Save",SaveAdd:"Save and Add Another",Cancel:"Cancel",NoChange:"No Change",NoX:"No {0}",nodata:"No data.",filters:{sEqual:"equals",sNotEqual:"not equal",sStart:"starts with",sContain:"contains",sFinish:"finishes with",sInList:"any of",sIsNull:"is empty",sIsNotNull:"is not empty",sBefore:"before",sAfter:"after",sNumEqual:"&#61;",sNumNotEqual:"!&#61;",sGreater:"&#62;",sSmaller:"&#60;",sOn:"on",sNotOn:"not on",sAt:"at",sNotAt:"not at",sBetween:"between",opAnd:"and",yes:"Yes",no:"No",bNewFilter:"New filter",bAddFilter:"Add filter",bUpdateFilter:"Update filter",bSubmit:"Submit",bCancel:"Cancel"}},Evol=Evol||{},EvoUI=Evol.UI,EvoDico=Evol.Dico;Evol.ViewMany=Backbone.View.extend({cardinality:"n",options:{style:"panel-info",pageSize:20,title:"#title",selectable:!0},events:{"click a.evol-nav-id":"click_navigate","click .evol-sort-icons > span":"click_sort","click .button.edit":"click_pagination","click .evol-field-label .glyphicon-wrench":"click_customize"},initialize:function(a){var b=this;this.options.mode=a.mode,this.options.uiModel=a.uiModel,this.model&&this.model.collection.on("change",function(a){b.render()})},customize:function(){var a=this.$("th > span");return this._custOn?(a.find("i").remove(),this._custOn=!1):(a.append(EvoUI.icons.customize("id","field")),this._custOn=!0),this},render:function(){var a=[];return this.model&&this.model.collection&&this.model.collection.length>0?this.renderList(a,this.options.mode):a.push(EvoUI.HTMLMsg(EvolLang.nodata,"","info")),this._updateTitle(),this.$el.html(a.join("")),this},setModel:function(a){return this.model=a,this.render(),this},updateModel:function(){alert("updateModel")},_updateTitle:function(){},getFields:function(){if(!this._fields){this._fields=EvoDico.fields(this.options.uiModel,function(a){return a.viewmany}),this._fieldHash={};var a=this;_.each(this._fields,function(b){a._fieldHash[b.id]=b})}return this._fields},getField:function(a){return this._fieldHash[a]},_hashLov:{},_lovText:function(a,b){if("list"in a&&a.list.length>0){a.id in this._hashLov||(this._hashLov[a.id]={});var c=this._hashLov[a.id];if(b in c)return c[b];_.each(a.list,function(a){if(a.id==b){var d=a.text;return a.icon&&(d='<img src="'+a.icon+'"> '+d),c[b]=a.text,a.text}})}return""},_HTMLField:function(a,b){switch(a.type){case EvoDico.fieldTypes.bool:if("true"===b||"1"==b)return EvoUI.icon("ok");break;case EvoDico.fieldTypes.lov:if(""!==b)return this._lovText(a,b);break;case EvoDico.fieldTypes.date:case EvoDico.fieldTypes.time:case EvoDico.fieldTypes.datetime:if(""!==b){var c=new Date(b);if(_.isDate(c)){var d="";return a.type!=EvoDico.fieldTypes.time&&(d+=EvoUI.formatDate(c)),a.type==EvoDico.fieldTypes.datetime&&(d+=" "),a.type!=EvoDico.fieldTypes.date&&(d+=EvoUI.formatTime(c)),d}}break;default:return b}return""},_paginationSummaryHTML:function(a,b,c,d,e){var f,g=a*b+1;if(1>a){if(0===c)return c+" "+e;if(1===c)return c+" "+d;f=_.min([b,c])}else f=_.min([g+b,c]);return["<p>",g,"-",f," of ",c," ",e,"</p>"].join("")},_paginationHTML:function(a,b,c){var d=a*b+1,e=parseInt(c/b,10),f=e>5?5:e,g=['<ul class="pagination pagination-sm">'];a>0&&g.push('<li data-id="prev"><a href="#">&laquo;</a></li>');for(var h=d;f>h;h++)g.push('<li data-id="',h,'"><a href="#">',h,"</a></li>");return c>(a+1)*b&&g.push('<li data-id="next"><a href="#">&raquo;</a></li>'),g.push("</ul>"),g.join("")},sortList:function(a,b){var c=this.model.collection;a.type==EvoDico.fieldTypes.text||a.type==EvoDico.fieldTypes.txtm||a.type==EvoDico.fieldTypes.email?c.comparator=EvoDico.bbComparatorText(a.id):c.comparator=EvoDico.bbComparator(a.id),c.sort(),b&&c.models.reverse(),this.render(),this.$el.trigger("list.sort",{id:a.id,direction:b?"down":"up"})},click_navigate:function(a){var b=$(a.currentTarget),c="list"===this.options.mode?"tr":"div";a.type="list.navigate",this.$el.trigger(a,{id:b.closest(c).data("id")})},click_sort:function(a){var b=$(a.currentTarget),c=b.parent().data("fid"),d=this.getField(c),e=b.attr("class").indexOf("-down")>0;this.sortList(d,e),b.addClass("evol-last-sort")},click_pagination:function(a){this.$el.trigger("list.paginate",{id:$(a.currentTarget).closest("li").data("id")})},click_customize:function(a){var b=$(a.currentTarget),c=b.data("id"),d=b.data("type");EvoDico.showDesigner(c,d,b),this.$el.trigger(d+".customize",{id:c,type:d})}});var Evol=Evol||{},EvoUI=Evol.UI,EvoDico=Evol.Dico;Evol.ViewMany.Cards=Evol.ViewMany.extend({viewName:"cards",options:{style:"panel-info",pageSize:20,title:"#title",selectable:!0},customize:function(){var a=this.$("h4 > a.evol-nav-id");return this._custOn?(a.find("i").remove(),this._custOn=!1):(a.append(EvoUI.icons.customize("id","field")),this._custOn=!0),this},render:function(){var a=[];return this.model&&this.model.collection&&this.model.collection.length>0?this._render(a,this.options.mode):a.push(EvoUI.HTMLMsg(EvolLang.nodata,"","info")),this._updateTitle(),this.$el.html(a.join("")),this},_render:function(a,b){var c=this.options,d=c.uiModel,e=this.model.collection.models,f=c.pageSize||50,g=this._paginationSummaryHTML(0,f,e.length,d.entity,d.entities);a.push('<div class="evol-many-',b,'">'),this._HTMLcards(a,this.getFields(),f,d.icon),"charts"!=b&&a.push(g,this._paginationHTML(0,f,e.length)),a.push("</div>")},_HTMLcards:function(a,b,c,d){var e=this.model.collection.models,f=_.min([e.length,c]);if(f>0){for(var g=0;f>g;g++){a.push('<div class="panel ',this.options.style,'">');for(var h=0;h<b.length;h++){var i=b[h],j=e[g],k=j.get(i.id);a.push('<div data-id="',j.id,'">'),0===h?(a.push('<h4><a href="#" id="fg-',i.id,'" class="evol-nav-id">'),d&&a.push('<img class="evol-table-icon" src="pix/',d,'">'),a.push(this._HTMLField(i,k)),a.push("</a></h4>")):a.push(this._HTMLField(i,k)),a.push("</div>")}a.push("</div>")}a.push(EvoUI.html.clearer)}else a.push(EvoUI.HTMLMsg(EvolLang.nodata,"","info"))}});var Evol=Evol||{},EvoUI=Evol.UI,EvoDico=Evol.Dico;Evol.ViewMany.Charts=Evol.ViewMany.extend({viewName:"chart",options:{style:"panel-info",pageSize:20,title:"#title",selectable:!0},events:{"click .evol-field-label .glyphicon-wrench":"click_customize"},render:function(){var a=[];if(this.model&&this.model.collection&&this.model.collection.length>0){var b=this.options,c=b.uiModel,d=b.pageSize||50;a.push('<div class="evol-many-',this.viewName,'">'),this._HTMLcharts(a,this.getFields(),d,c.icon),a.push("</div>")}else a.push(EvoUI.HTMLMsg(EvolLang.nodata,"","info"));return this._updateTitle(),this.$el.html(a.join("")),this},_HTMLcharts:function(a){var b=this,c=this.options.uiModel,d=this.model,e=d.collection.models,f=EvoDico.fields(c,function(a){return a.type==EvoDico.fieldTypes.lov||a.type==EvoDico.fieldTypes.bool});_.each(f,function(d){var f=_.countBy(e,function(a){return a.get(d.id)}),g=f,h=[],i=[];for(var j in g){var k=g[j];h.push(k),EvoDico.isTypeDateOrTime(d)?i.push(b._lovText(d,j)+" ("+k+")"):d.type==EvoDico.fieldTypes.lov?i.push(b._lovText(d,j)+" ("+k+")"):i.push(j+" ("+k+")")}var l=EvoUI.capFirstLetter(c.entities);d.type==EvoDico.fieldTypes.lov?a.push(EvoUI.Charts.Pie(l+" by "+d.label,h,i)):a.push(EvoUI.Charts.Bars(l+": "+d.label,h,i))}),a.push(EvoUI.html.clearer)}});var Evol=Evol||{},EvoUI=Evol.UI,EvoDico=Evol.Dico;Evol.ViewMany.List=Evol.ViewMany.extend({viewName:"list",options:{style:"panel-info",pageSize:20,selectable:!0},render:function(){var a=[];return this.model&&this.model.collection&&this.model.collection.length>0?this._render(a,this.options.mode):a.push(EvoUI.HTMLMsg(EvolLang.nodata,"","info")),this._updateTitle(),this.$el.html(a.join("")),this},_render:function(a,b){var c=this.options,d=c.uiModel,e=this.model.collection.models,f=c.pageSize||50,g=this._paginationSummaryHTML(0,f,e.length,d.entity,d.entities);a.push('<div class="evol-many-',b,'">'),this["_HTML"+b.replace(/-/g,"_")](a,this.getFields(),f,d.icon),"charts"!=b&&a.push(g,this._paginationHTML(0,f,e.length)),a.push("</div>")},_HTMLlist:function(a,b,c,d){a.push('<div class="panel ',this.options.style,'">'),a.push('<table class="table table-bordered table-hover"><thead>');for(var e=0;e<b.length;e++)this._renderListHeader(a,b[e]);a.push("</thead><tbody>"),this._HTMLlistbody(a,b,c,d),a.push("</tbody></table></div>")},_HTMLlistbody:function(a,b,c,d){var e=this.model.collection.models,f=_.min([e.length,c]);if(f>0)for(var g=0;f>g;g++)this._HTMLlistrow(a,b,e[g],d)},_HTMLlistrow:function(a,b,c,d){a.push('<tr data-id="',c.cid,'">');for(var e=0;e<b.length;e++){var f=b[e],g=c.escape(f.id);a.push("<td>"),0===e&&(a.push('<a href="javascript:void(0)" id="fv-',f.id,'" class="evol-nav-id">'),d&&a.push('<img class="evol-table-icon" src="pix/',d,'">')),a.push(this._HTMLField(f,g)),0===e&&a.push("</a>"),a.push("</td>")}a.push("</tr>")},_renderListHeader:function(a,b){a.push('<th><span id="',b.id,'-lbl">',b.label,'<span class="evol-sort-icons" data-fid="',b.id,'">',EvoUI.icon("chevron-up"),EvoUI.icon("chevron-down"),"</span></span></th>")}});var Evol=Evol||{},EvoUI=Evol.UI,EvoDico=Evol.Dico;Evol.ViewOne=Backbone.View.extend({events:{"click > .evol-buttons > button":"click_button","click .evol-title-toggle":"click_toggle","click ul.evol-tabs > li > a":"click_tab","click label > .glyphicon-question-sign":"click_help","click .evol-field-label .glyphicon-wrench":"click_customize"},cardinality:"1",options:{button_addAnother:!1,style:"panel-info",titleSelector:""},initialize:function(a){var b=this,c=a.mode;this.options.mode=c,this.options.uiModel=a.uiModel,this.model&&this.model.on("change",function(a){b.setModel(a)})},render:function(){var a=this.options.mode,b=[];return"json"===a?this.renderJSON(b,a):this.renderEdit(b,a),this.$el.html(b.join("")),this.setData(this.model),this._updateTitle(),this.custOn=!1,this},getFields:function(a){if(!this._fields){this._fields=EvoDico.fields(this.options.uiModel,a),this._fieldHash={};var b=this;_.each(this._fields,function(a){b._fieldHash[a.id]=a})}return this._fields},setModel:function(a){this.model=a,this.clearMessages(),this.setData(a)},setUIModel:function(a){this.options.uiModel=a;var b=this.getData();this.render().setData(b)},modelUpdate:function(a){var b=this;_.each(a.changed,function(a,c){b.setFieldValue(c,a)})},getData:function(){var a=this,b={},c=this.getFields();return _.each(c,function(c){b[c.id]=a.getFieldValue(c)}),b},setData:function(a){var b,c=this.getFields(),d=this,e="#"+d.prefix+"-";_.each(c,function(c){if(b=d.$(e+c.id),a)switch(c.type){case"boolean":b.prop("checked",a.get(c.id));break;default:b.val(a.get(c.id))}}),this._updateTitle()},_updateTitle:function(){},clear:function(){var a,b=this.getFields(),c=this,d="#"+c.prefix+"-";return this.clearMessages(),_.each(b,function(b){switch(a=c.$(d+b.id),b.type){case"boolean":a.prop("checked",b.defaultvalue||"");break;default:a.val(b.defaultvalue||"")}}),this},setFieldValue:function(a,b){return this.$("#"+this.fieldViewId(a)).val(b),this},getFieldValue:function(a){var b=this.$("#"+this.prefix+"-"+a.id);switch(a.type){case EvoDico.fieldTypes.bool:return b.prop("checked");default:return b.val()}},showTab:function(a){var b=this.$(a);return b.length>0&&(b.siblings(".tab-pane").hide(),b.show()),b=this.$('.evol-tabs > li a[href="'+a+'"]').parent(),b.length>0&&(b.siblings("li").removeClass("active"),b.addClass("active")),this.$el.trigger("tab.show"),this},_renderButtons:function(a,b){a.push(EvoUI.html.clearer,'<div class="evol-buttons">',EvoUI.inputButton("cancel",EvolLang.Cancel,"btn-default"),EvoUI.inputButton("save",EvolLang.Save,"btn-primary")),this.options.button_addAnother&&"json"!==b&&a.push(EvoUI.inputButton("save-add",EvolLang.SaveAdd,"btn-default")),a.push("</div>")},renderEdit:function(a,b){var c=-1,d=-1,e=this.options,f=e.uiModel.elements;if("mini"===b){var g=EvoDico.fields(e.uiModel,function(a){return a.searchlist||a.required||a.mini},e.mode),h={type:"panel","class":"evo-mini-holder",label:EvoUI.capFirstLetter(e.uiModel.entity),width:100,elements:g};this.renderPanel(a,h,"evo-one-mini",b)}else{a.push('<div class="evo-one-',b,'">');for(var i=0,j=f.length;j>i;i++){var k=f[i];switch(k.type){case"tab":d>0&&(a.push("</div>"),d=-1),0>c&&(a.push(EvoUI.html.clearer),this.renderTabs(a,f),a.push('<div class="tab-content">')),c++,a.push('<div id="evol-tab-',i,'" class="tab-pane',1===i?' active">':'">'),this.renderTab(a,k,b),c==j-1&&a.push("</div>");break;case"panel":0>d&&(a.push('<div class="evol-pnls">'),d=1),this.renderPanel(a,k,"pe-"+i,b);break;case"panel-list":0>d&&(a.push(""),d=1),this.renderPanelList(a,k,"pe-"+i,b)}}d>0&&a.push("</div>"),a.push("</div>")}this._renderButtons(a,b),this._updateTitle()},renderTabs:function(a,b){var c=!0;a.push('<ul class="nav nav-tabs evol-tabs">'),_.each(b,function(b,d){"tab"==b.type&&(c?(a.push('<li class="active">'),c=!1):a.push("<li>"),a.push('<a href="#evol-tab-',d,'">',b.label,"</a></li>"))}),a.push("</ul>")},renderTab:function(a,b,c){var d=this;a.push('<div class="evol-pnls">'),_.each(b.elements,function(b,e){"panel-list"===b.type?d.renderPanelList(a,b,"pl-"+e,c):d.renderPanel(a,b,"pl-"+e,c)}),a.push(EvoUI.html.clearer,"</div></div>")},renderPanel:function(a,b,c,d){var e=this;"mini"===d?(a.push('<div data-p-width="',b.width,'" class="w-100 evol-pnl ',b["class"]||"",'">','<div class="panel ',this.options.style,'">',EvoUI.HTMLPanelLabel(b.label,c,"PanelLabel"),'<fieldset data-pid="',c,'">'),_.each(b.elements,function(b){a.push('<div class="pull-left evol-fld w-100">'),e.renderField(a,b,d),a.push("</div>")})):(a.push('<div style="width:',b.width,'%" data-p-width="',b.width,'" class="pull-left evol-pnl">','<div class="panel ',this.options.style,'">',EvoUI.HTMLPanelLabel(b.label,c,"PanelLabel"),'<fieldset data-pid="',c,'">'),_.each(b.elements,function(b){a.push('<div style="width:',parseInt(b.width,10),'%" class="pull-left evol-fld">'),e.renderField(a,b,d),a.push("</div>")})),a.push("</fieldset></div></div>")},renderPanelList:function(a,b,c,d){a.push('<div style="width:',b.width,'%" class="pull-left evol-pnl">','<div class="panel ',this.options.style,'">',EvoUI.HTMLPanelLabel(b.label,c,"PanelLabel"),'<table width="100%" class="table-striped"><tr>'),_.each(b.elements,function(b){a.push("<th>",b.label,"</th>")}),a.push("</tr><tr>"),_.each(b.elements,function(b){a.push("<td>",b.label,"</td>")}),a.push("</tr></table></div></div>")},renderField:function(a,b,c){function d(a){return a.toLocaleLowerCase().replace(/ /g,"_").replace(/\(/g,"").replace(/\)/g,"")}var e,f,g,h=EvoDico.fieldTypes;if(b.id&&""!==b.id?e=b.id:(e=d(b.label),b.id=e),this.model&&this.model.has(e)&&(f="new"!=c?this.model.get(e):b.defaultvalue?b.defaultvalue:""),e=this.fieldViewId(e),"mini"===c?(g=b.width,b.width=100,a.push('<div class="evo-mini-label">'),this.renderFieldLabel(a,b,c),a.push('</div><div class="evo-mini-content">')):this.renderFieldLabel(a,b,c),b.readonly>0)a.push('<div id="',e,'" class="FieldReadOnly">',f,"&nbsp;</div>");else switch(b.type){case h.text:a.push(EvoUI.inputText(e,f,b));break;case h.email:"view"===c?a.push(EvoUI.link(e,f,"mailto:"+HttpUtility.HtmlEncode(f))):a.push(EvoUI.inputText(e,f,b.maxlength));break;case h.url:"view"===c?a.push(EvoUI.link(e,f,HttpUtility.HtmlEncode(f))):a.push(EvoUI.inputText(e,f,b.maxlength));break;case h.integer:case h.dec:a.push(EvoUI.inputTextInt(e,f));break;case h.bool:a.push(EvoUI.inputCheckbox(e,f));break;case h.txtm:case h.html:null===b.height?b.height=5:(fHeight=parseInt(b.height,10),fHeight<1&&(b.height=5)),a.push(EvoUI.inputTextM(e,f,b.maxlength,b.height));break;case h.date:a.push(EvoUI.inputDate(e,f));break;case h.datetime:a.push(EvoUI.inputDateTime(e,f));break;case h.time:a.push(EvoUI.inputTime(e,f));break;case h.color:a.push(EvoUI.inputColor(e,f));break;case h.lov:a.push(EvoUI.inputLOV(e,f,"",b.list||[]));break;case h.integer:a.push(EvoUI.inputTextInt(e,f,b.type,b.max,b.min));break;case h.pix:""===f?a.push('<p class="">No picture</p>'):a.push('<img src="',f,'" class="img-thumbnail">')}"mini"===c&&(a.push("</div>"),b.width=g)},renderFieldLabel:function(a,b,c){a.push('<div class="evol-field-label" id="',b.id,'-lbl"><label class="control-label" for="',b.id,'">',b.label),"view"!=c&&b.required>0&&a.push('<span class="evol-required">*</span>'),b.help&&""!==b.help&&a.push(EvoUI.icon("question-sign","")),a.push("</label></div>")},validate:function(){var a=this.getFields();return this.clearMessages(),_.isArray(a)?(this.$el.trigger("view.validate"),EvoVal.checkFields(this.$el,a,this.prefix)):!1},clearErrors:function(){return this.$(".control-group.error").removeClass("control-group error"),this.$(".has-error").removeClass("has-error"),this.$(".text-danger").remove(),this},commit:function(a,b){var c=this.validate();return""===c?"new"===this.options.mode?this.model.collection.create(this.getData(),{success:a,error:b}):(this.model.set(this.getData()),this.model.save({success:a,error:b})):this.setMessage("Invalid data",c,"warning"),this},fieldViewId:function(a){return this.prefix+"-"+a},customize:function(){var a=".evol-field-label > label",b=".evol-pnl .panel-title";return this.custOn?(this.$(a+" > i, "+b+" > i").remove(),this.custOn=!1):(_.each(this.$(a),function(a){var b=$(a),c=b.attr("for");b.append(EvoUI.icons.customize(c,"field"))}),this.$(b).append(EvoUI.icons.customize("id","panel")),this.custOn=!0),this},showHelp:function(a,b,c){var d=EvoDico.fields(this.options.uiModel),e=_.findWhere(d,{id:a});if(e||e.help){var f=c.closest(".evol-fld"),g=f.find(".help-block");if(g.length>0)g.slideUp(300,function(){g.remove()});else{var h=$('<span class="help-block">'+_.escape(e.help)+"</span>").hide();f.append(h),h.slideDown(300)}}return this},setMessage:function(a,b,c){var d=this.$('[data-id="msg"]');d.length?d.html("<strong>"+a+"</strong>"+b):this.$el.prepend(EvoUI.HTMLMsg(a,b,c))},clearMessage:function(){var a=this.$('[data-id="msg"]').fadeOut(300,function(){a.remove()})},clearMessages:function(){return this.clearErrors().clearMessage()},click_button:function(a){var b=this;$(a.currentTarget).attr("id");a.stopImmediatePropagation(),this.commit(function(){b.setMessage("Record Saved","Record was saved.","success")},function(){alert("error")})},click_toggle:function(a){var b=$(a.target),c=b.closest(".panel-heading").next(),d=c.data("expState");a.preventDefault(),a.stopImmediatePropagation(),a.shiftKey?(b=this.$(".evol-title-toggle"),b="down"===d?this.$(".evol-title-toggle.glyphicon-chevron-down").trigger("click"):this.$(".evol-title-toggle.glyphicon-chevron-up").trigger("click")):"down"===d?(b.closest(".panel").css("height",""),c.slideDown(400).data("expState","up"),b.addClass("glyphicon-chevron-up").removeClass("glyphicon-chevron-down")):(c.slideUp(400,function(){b.closest(".panel").css("height","40px")}).data("expState","down"),b.removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down")),this.$el.trigger("panel.toggle")},click_tab:function(a){var b=a.target.href,c=b.substring(b.indexOf("#"));a.stopImmediatePropagation(),a.preventDefault(),a.shiftKey?this.$(".tab-content > div").show():this.showTab(c)},click_help:function(a){var b=$(a.currentTarget),c=b.closest("label").attr("for"),d=b.data("type");a.stopImmediatePropagation(),this.showHelp(c,d,b),this.$el.trigger(d+".help",{id:c})},click_customize:function(a){var b=$(a.currentTarget),c=b.data("id"),d=b.data("type");a.stopImmediatePropagation(),EvoDico.showDesigner(c,d,b),this.$el.trigger(d+".customize",{id:c,type:d})}});var EvoVal={checkMaxLen:function(a,b){a.value.length>b&&(a.value=a.value.substring(0,b-1))},checkNum:function(a,b){var c,d=a.value;if("i"==b.substring(0,1))c=parseInt(d,10);else{var e=EvolLang.LOCALE;"FR"!=e&&"DA"!=e||(d=d.replace(",",".")),c=parseFloat(d)}isNaN(c)?a.value="":d!=c&&(a.value=c)},setValidationFlags:function(a,b){var c=a.find(".text-danger");c.length?c.html(b):a.append('<p class="text-danger">'+b+"</p>"),a.addClass("has-error")},checkFields:function(a,b,c){function d(){var a=EvoDico.fieldTypes,b=EvoUI.trim(l.val());if(""!==b)switch(k.type){case a.integer:case a.email:h[k.type].test(b)||EvoVal.setValidationFlags(l.parent(),g(EvolLang[k.type]));break;case a.dec:var c=h[k.type+EvolLang.LOCALE];null===c&&(c=h[k.type+"EN"]),c.test(b)||EvoVal.setValidationFlags(l.parent(),g(EvolLang[k.type]));break;case a.date:case a.datetime:""===b||_.isDate(new Date(b))||EvoVal.setValidationFlags(l.parent(),g(EvolLang[k.type]))}}function e(a,b){var c,d=a.tagName;return c="SELECT"==d&&a.get(0).selectedIndex>-1?"0"==f.options[a.get(0).selectedIndex].value:""===EvoUI.trim(a.val())}function g(a,b){var c=a.replace("{0}",k.label);return null!==b&&(c=c.replace("{1}",b)),i.push(c),c}var h={email:/^[\w\.\-]+@[\w\.\-]+\.[\w\.\-]+$/,integer:/^-?\d+$/,decimalEN:/^\d+(\.\d+)?$/,decimalFR:/^\d+(\,\d+)?$/,decimalDA:/^\d+(\,\d+)?$/},i=[];for(var j in b){var k=b[j],l=a.find("#"+c+"-"+k.id).eq(0),m="html"==k.type;if(m&&l.val(nicEditors.findEditor(f.id).getContent()),l.length>0){var n,o,p=!0;if(k.required>0?e(l,m)?(n=l.parent(),o=g(EvolLang.validation.empty),EvoVal.setValidationFlags(n,o),p=!1):(l.parent().removeClass("control-group error").find(".evol-warn-error").remove(),d()):d(),null!==k.rg&&void 0!==k.rg){var q=new RegExp(k.rg);l.val().match(q)||(n=l.parent(),o=g(EvolLang.validation.reg,k.rg),EvoVal.setValidationFlags(l.parent(),o))}if(p){var r=EvoUI.trim(l.val());""!==r&&(null!==k.max&&parseFloat(r)>k.max&&EvoVal.setValidationFlags(l.parent(),g(EvolLang.validation.max,k.max)),null!==k.min&&parseFloat(r)<k.min&&EvoVal.setValidationFlags(l.parent(),g(EvolLang.validation.min,k.min)))}}}return i.length>0?[EvolLang.validation.intro,"<ul><li>",i.join("<li>"),"</li></ul>"].join(""):""}},Evol=Evol||{},EvoUI=Evol.UI,EvoDico=Evol.Dico;Evol.ViewOne.Edit=Evol.ViewOne.extend({viewName:"edit",prefix:"oe",render:function(){var a=[];return this.renderEdit(a,"edit"),this.$el.html(a.join("")),this.setData(this.model),this._updateTitle(),this.custOn=!1,this},renderEdit:function(a){var b=-1,c=-1,d=this.options,e=d.uiModel.elements,f="edit";a.push('<div class="evo-one-',f,'">');for(var g=0,h=e.length;h>g;g++){var i=e[g];switch(i.type){case"tab":c>0&&(a.push("</div>"),c=-1),0>b&&(a.push(EvoUI.html.clearer),this.renderTabs(a,e),a.push('<div class="tab-content">')),b++,a.push('<div id="evol-tab-',g,'" class="tab-pane',1===g?' active">':'">'),this.renderTab(a,i,f),b==h-1&&a.push("</div>");break;case"panel":0>c&&(a.push('<div class="evol-pnls">'),c=1),this.renderPanel(a,i,"pe-"+g,f);break;case"panel-list":0>c&&(a.push(""),c=1),this.renderPanelList(a,i,"pe-"+g,f)}}c>0&&a.push("</div>"),a.push("</div>"),this._renderButtons(a,f),this._updateTitle()}});var Evol=Evol||{},EvoUI=Evol.UI,EvoDico=Evol.Dico;Evol.ViewOne.JSON=Evol.ViewOne.extend({events:{"click > .evol-buttons > button":"click_button","click .evol-title-toggle":"click_toggle","click .evol-field-label .glyphicon-wrench":"click_customize"},viewName:"json",prefix:"oj",render:function(){var a=[];if(this.model){var b=JSON.stringify(this.model.toJSON(),null,2);a.push(EvoUI.inputTextMJSON("",b,10))}return this._renderButtons(a,"json"),this.$el.html(a.join("")),this.setData(this.model),this._updateTitle(),this.custOn=!1,this},getData:function(){var a=this.$el.children("textarea").val();return $.parseJSON(a)},setData:function(a){var b=this;"#"+b.prefix+"-";this.$el.children("textarea").val(JSON.stringify(a,null,2)),this._updateTitle()},clear:function(){return this.$el.children("textarea").val(""),this}});var Evol=Evol||{},EvoUI=Evol.UI,EvoDico=Evol.Dico;Evol.ViewOne.Mini=Evol.ViewOne.extend({events:{"click > .evol-buttons > button":"click_button","click .evol-title-toggle":"click_toggle","click label > .glyphicon-question-sign":"click_help"},viewName:"mini",prefix:"om",getFieldsCondition:function(a){return a.required||a.viewmany||a.viewmini},render:function(){var a=this.options.mode,b=[];
return this.renderEdit(b,a),this.$el.html(b.join("")),this.setData(this.model),this._updateTitle(),this.custOn=!1,this},renderEdit:function(a,b){var c=this.options,d=this.getFields(),e={type:"panel","class":"evo-mini-holder",label:EvoUI.capFirstLetter(c.uiModel.entity),width:100,elements:d};this.renderPanel(a,e,"evo-one-mini",b),this._renderButtons(a,b),this._updateTitle()}});var Evol=Evol||{},EvoUI=Evol.UI,EvoDico=Evol.Dico;Evol.ViewToolbar=Backbone.View.extend({events:{"click .nav a":"click_toolbar","list.navigate div":"click_navigate"},options:{toolbar:!0,defaultView:"list",style:"normal",buttons:{edit:!0,mini:!0,json:!0,list:!0,cards:!0,charts:!0,"new":!0,del:!0,filter:!0,"export":!0,group:!0,customize:!0}},modesHash:{edit:"Edit",mini:"Mini",json:"JSON",cards:"Cards",list:"List",charts:"Charts"},views:[],viewsHash:{},curView:null,curViewName:"",initialize:function(a){var b=this.options;b.mode=a.mode,b.uiModel=a.uiModel,b.defaultView=a.defaultView,this.render(),this.$('[data-cid="views"] > li').tooltip(),this.$(".dropdown-toggle").dropdown()},render:function(){var a=this.$el;a.html(this._toolbarHTML()),this.setView(this.options.defaultView||"list")},_toolbarHTML:function(){function a(a,b,d,e,f){c.push('<li data-id="',a,'"'),e&&c.push(' data-cardi="'+e,'"'),f&&""!==f&&c.push(' data-toggle="tooltip" data-placement="bottom" title="" data-original-title="',f,'"'),c.push('><a href="#" data-id="',a,'">',EvoUI.icon(d)),b&&""!==b&&c.push("&nbsp;",b),c.push("</a></li>")}function b(b,c,e,f,g){d.buttons&&d.buttons[b]&&a(b,c,e,f,g)}var c=[],d=this.options;return c.push('<div class="evo-toolbar"><ul class="nav nav-pills pull-left" data-cid="main">'),b("list",EvolLang.All,"th-list"),b("new",EvolLang.New,"plus"),b("del",EvolLang.Delete,"trash","1"),d&&(a("prev","","chevron-left","1"),a("next","","chevron-right","1"),c.push('</ul><ul class="nav nav-pills pull-right" data-cid="views">'),b("list","","th-list","n","List"),b("cards","","th-large","n","Cards"),b("charts","","stats","n","Charts"),b("edit","","th","1","All Fields"),b("mini","","th-large","1","Important Fields only"),b("json","","barcode","1","JSON")),c.push("</ul>",EvoUI.html.clearer,"</div>"),c.join("")},updateModel:function(a){this.refresh()},refresh:function(){return this.viewsHash.list&&this.viewsHash.list.render(),this.viewsHash.cards&&this.viewsHash.cards.render(),this},setView:function(a){var b,c=this.$el,d="evolw-"+a,e=this.$('[data-vid="'+d+'"]'),f=this.curView;if("new"===a)a=this._prevOne?this._prevOne:"edit",this.setView(a),this._isNew=!0,this.curView.clear(),this.curView.options.mode="new";else{if(this._isNew=!1,e.length)this.curView=this.viewsHash[a],this.isNew||this.curView.setModel(this.model),this.$('[data-cid="views"] > li').removeClass("evo-sel").filter('[data-id="'+a+'"]').addClass("evo-sel"),e.show().siblings().not(".evo-toolbar,.evo-filters,.clearfix").hide();else{switch(e=$('<div data-vid="evolw-'+a+'"></div>'),c.children().not(".evo-toolbar,.evo-filters,.clearfix").hide(),c.append(e),b={el:e,mode:a,model:this.model,uiModel:this.options.uiModel},this.$('[data-id="new"]').show(),this.$('[data-cid="views"] > li').removeClass("evo-sel").filter('[data-id="'+a+'"]').addClass("evo-sel"),a){case"edit":case"mini":case"json":f=new Evol.ViewOne[this.modesHash[a]](b).render(),this._prevOne=a;break;case"charts":case"cards":case"list":f=new Evol.ViewMany[this.modesHash[a]](b).render(),this._prevMany=a;break;case"export":f=new Evol.ViewExport(b)}this.curView=f,this.curViewName=a,this.viewsHash[a]=f}this.curView.options.mode=a}return this.setToolbar(a,this._isNew),this},getToolbarButtons:function(){if(!this._toolbarButtons){var a=this.$("li");this._toolbarButtons={ones:a.filter('[data-cardi="1"]'),manys:a.filter('li[data-cardi="n"]'),prevNext:this.$('[data-id="prev"],[data-id="next"]'),customize:this.$('a[data-id="customize"]').parent()}}return this._toolbarButtons},setToolbar:function(a){function b(a,b){EvoUI.setVisible(c.ones,a),EvoUI.setVisible(c.manys,b)}if(this.$el){var c=this.getToolbarButtons();EvoUI.setVisible(c.customize,"json"!=a),c.prevNext.hide(),this._isNew||"export"===a?b(!1,!1):"cards"===a||"list"===a||"charts"===a?(this._prevMany=a,b(!1,!0)):(this._prevOne=a,b(!0,!1),c.prevNext.show()),"cards"===a?c.manys.filter('[data-id="group"]').show():c.manys.filter('[data-id="group"]').hide()}},setData:function(a){return this.curView&&this.curView.setData(a),this},getData:function(){return this.curView?this.curView.getData():null},browse:function(a){var b=this.curView.model;if(this.model&&this.model.collection&&this.model.collection.length){var c=this.model.collection,d=c.length-1,e=_.indexOf(c.models,b);e="prev"===a?e>0?e-1:d:d>e?e+1:0,b=c.models[e]}else b=null;return this.model=b,this.curView.setModel(b),this},click_toolbar:function(a){var b=this,c=$(a.target);"A"!==c.tagName&&(c=c.closest("a"));var d=c.data("id");switch(a.preventDefault(),a.stopImmediatePropagation(),d){case"del":if(confirm("Are you sure you want to delete this record?")){var e=this.curView.model,f=e.collection.at(0);this.model=f,b.curView.setModel(f),e.destroy({success:function(){b.curView.setMessage("Record Deleted","Record was removed.","success")},error:function(a){alert("error")}})}break;case"customize":this.curView.customize();break;case"group":this.showGroup();break;case"filter":this.showFilter();break;case"prev":case"next":this.browse(d);break;case"new-field":case"new-panel":EvoDico.showDesigner("id","field",c);break;default:d&&""!==d&&this.setView(d)}a.stopImmediatePropagation(),this.$el.trigger("toolbar."+d)},click_navigate:function(a,b){var c=this.model.collection.get(b.id);this.model=c,this.setView(this._prevOne||"edit"),this.curView.model=c,this.curView.render(),a.stopImmediatePropagation()}});var Evol=Evol||{},EvoUI=Evol.UI,EvoDico=Evol.Dico,evoLangXpt=EvolLang["export"];Evol.ViewExport=Backbone.View.extend({version:"0.0.1",events:{"change select.evol-xpt-format":"click_format","change input":"click_preview","click .evol-more":"click_toggle_sel","click #XP":"click_submit"},options:{toolbar:!0,cardinality:"one",model:null,uiModel:null,defaultView:"list",style:"normal",prefix:"tbr"},many:!0,viewName:"export",initialize:function(a){this.options.fields=a.fields,this.options.uiModel=a.uiModel,this.options.prefix=a.prefix,this.render();var b=this.$el;return b.addClass("Panel"),this._preview("CSV"),this},render:function(){return this.$el.html(this._renderHTML()),this._preview("CSV"),this},_renderHTML:function(){var a=[],b=this.options,c=b.prefix||"",d=this.getFields();a.push('<table class="evol-xpt-form"><tr><td class="evol-xpt-flds"><fieldset>'),a.push('<div class="evol-id">',EvoUI.fieldLabel("",evoLangXpt.ExportFields),EvoUI.inputCheckbox("showID","1"),'<label for="showID">',evoLangXpt.IDkey,"</label>","</div>");for(var e=0,f=d.length;f>e;e++){var g=d[e],h=g.label,i="fx-"+g.id;null!==h&&""!==h||(h="("+i+")"),a.push('<div><input type="checkbox" value="1" id="',i,'" checked="true"><label class="checkbox" for="',i,'">',h,"</label></div>"),12==e&&f>16&&a.push(EvoExport.html_more2(evoLangXpt.AllFields))}f>16&&a.push("</div>"),a.push('</fieldset></td><td class="evol-xpt-para">');var j=c+"evol-xpt-format",k=evoLangXpt.ExportFormats.split("-");return a.push('<label for="',j,'">',evoLangXpt.ExportFormat,"</label>"),a.push(EvoUI.inputSelectBegin(j,"evol-xpt-format"),EvoUI.inputOption("CSV",k[0]),EvoUI.inputOption("TAB",k[3]),EvoUI.inputOption("HTML",k[1]),EvoUI.inputOption("JSON",k[5]),EvoUI.inputOption("SQL",k[2]),EvoUI.inputOption("XML",k[4]),"</select>"),a.push('<div class="evol-xpt-opts">'),j=c+"FLH",a.push('<div class="evol-FLH clearfix">'),a.push(EvoUI.inputCheckbox(j,!0),EvoUI.fieldLabelSpan(j,evoLangXpt.ExportFirstLine)),a.push('</div><div id="',c,'CSV">'),a.push('<div id="',c,'csv2" class="evol-w120">',EvoExport.html_more2("options"),EvoUI.fieldLabel("FLS_evol",evoLangXpt.ExportSeparator),EvoUI.inputText("FLS_evol",",",0),"</div></div>"),a.push("</div>"),_.each(["XML","HTML","SQL","JSON"],function(b){a.push('<div id="',c,b,'" style="display:none;"></div>')}),a.push("</div>"),a.push('<label>Export Preview</label><div class="evol-xpt-preview"></div>'),a.push("</td></tr></table>"),a.push('<div class="evol-buttons form-actions">'),a.push('<input class="btn btn-primary" id="XP" type="submit" value="',evoLangXpt.DownloadEntity.replace("{0}",this.options.uiModel.entities),'">'),a.push("</div>"),a.join("")},showFormatOpts:function(a){var b="#"+(this.prefix||"");this.$el;switch(a){case"TAB":a="CSV",this.$("#csv2").hide();break;case"CSV":this.$("#csv2").show();break;case"HTML":case"XML":case"SQL":case"JSON":var c=this.$(b+a);""===c.html()&&c.html(EvoExport["form"+a](this.options.uiModel.entity))}var d=this.$(b+a).show().siblings().hide(),e=d.filter(".evol-FLH");"TAB"===a||"CSV"===a?e.show():e.hide(),EvoExport.cFormat=a},getFields:function(){var a=this.options;return this.fields||(this.fields=EvoDico.fields(a.uiModel,a.fnFilter,a.mode)),this.fields},_preview:function(a){var b=this.model.collection.models,c=this.getFields(),d=['<textarea class="Field evol-xpt-val form-control">'],e=this.$(".evol-xpt-flds > fieldset input:checked"),f={};switch(_.each(e,function(a){f[a.id.substring(3)]=""}),c=_.filter(c,function(a){return a.id&&_.has(f,a.id)?!0:void 0}),a){case"CSV":case"TAB":case"TXT":var g=c.length-1,h=this.$("#FLS_evol").val().trim(),i=this.$("#FLH").prop("checked");"TAB"==a&&(h="&#09;"),i&&(_.each(c,function(a,b){d.push(a.label),g>b&&d.push(h)}),d.push("\n")),_.each(b,function(a){_.each(c,function(b,c){var e=a.get(b.id);e&&d.push(e),g>c&&d.push(h)}),d.push("\n")}),d.push("\n");break;case"HTML":d.push("<table>\n<tr>"),_.each(c,function(a){d.push("<th>",a.id,"</th>")}),d.push("</tr>\n"),_.each(b,function(a,b){d.push("<tr>"),_.each(c,function(b){var c=a.get(b.id);c?d.push("<td>",c,"</td>"):d.push("<td></td>")}),d.push("</tr>\n")}),d.push("</table>");break;case"JSON":d.push(JSON.stringify(this.model.toJSON(),null,2));break;case"SQL":var j=c.length-1,k=this.$("#evoxpTRS1").prop("checked"),l=this.$("#evoxpTRS2").prop("checked"),m=this.$("#evoTable").val().replace(/ /g,"_"),n=["INSERT INTO ",m," ("];_.each(c,function(a,b){n.push(a.id),j>b&&n.push(", ")}),n.push(")\n VALUES ("),n=n.join(""),k&&d.push("BEGIN TRANSACTION\n"),l&&d.push("SET IDENTITY_INSERT ",m," ON;\n");for(var o=0,p=b.length;p>o;o++){d.push(n);for(var q=b[o],r=0,s=c.length;s>r;r++){var t=q.get(c[r].id);d.push('"',t,'"'),j>r&&d.push(", ")}d.push(");\n")}l&&d.push("SET IDENTITY_INSERT ",m," OFF;\n"),k&&d.push("COMMIT TRANSACTION\n");break;case"XML":var u=this.$("#evoRoot").val();d.push("<xml>\n"),_.each(b,function(a){d.push("<",u," "),_.each(c,function(b){d.push(b.id,'="',a.get(b.id),'" ')}),d.push("></",u,">\n")}),d.push("</xml>")}d.push("</textarea>"),this.$(".evol-xpt-preview").html(d.join(""))},val:function(a){return"undefined"==typeof a?this._getValue():(this._setValue(a),this)},_ValFields:function(){for(var a=[],b=this.$(".evol-xpt-flds input:checked").not("#showID"),c=0,d=b.length;d>c;c++){var e=$(b[c]);a.push(e.attr("id"))}return a},_getValue:function(){var a={format:this._bFormat.val(),fields:this._ValFields(),options:{}},b=this.$(".evol-xpt-para input"),c=b.eq(0),d="undefined"!==c.attr("checked");return a.options[c.attr("id")]=d,a},click_format:function(a){var b=this.$(".evol-xpt-format").val();"XML"===b?(this.$("#XML").html(EvoExport.formXML(this.options.uiModel.entity)).show().siblings().not(".evol-FLH").hide(),EvoExport.cFormat="XML"):this.showFormatOpts(b),this._preview(b),this.$el.trigger("change.export","format",b)},click_preview:function(a){var b=this.$(".evol-xpt-format").val();this._preview(b)},click_toggle_sel:function(a){$(a.currentTarget).hide().next().slideDown()},click_submit:function(a){this.$el.trigger("submit.export")}});var EvoExport={cFormat:"CSV",html_more2:function(a){return['<a href="javascript:void(0)" class="evol-more">',a,'</a><div class="evol-more-content">'].join("")},formHTML:function(){return""},formXML:function(a){var b="evoxpC2X";return[EvoExport.html_more2("options"),EvoExport.formEntityName("evoRoot",evoLangXpt.xpXMLroot,a),EvoUI.fieldLabel(b,evoLangXpt.xpColMap),"</div>"].join("")},formJSON:function(){return""},formSQL:function(a){return[EvoExport.html_more2("options"),EvoExport.formEntityName("evoTable",evoLangXpt.xpSQLTable,a),"<div>",EvoUI.inputCheckbox("evoxpTRS2","0"),EvoUI.fieldLabelSpan("evoxpTRS2",evoLangXpt.xpSQLId),"</div>","<div>",EvoUI.inputCheckbox("evoxpTRS1","0"),EvoUI.fieldLabelSpan("evoxpTRS1",evoLangXpt.xpSQLTrans),"</div>","</div>"].join("")},formEntityName:function(a,b,c){return[EvoUI.fieldLabel(a,b),EvoUI.inputText(a,c.replace(" ","_"),30),"<br/>"].join("")}},Evol=Evol||{},EvoUI=Evol.UI,EvoDico=Evol.Dico,evoLang=EvolLang.filters,evoAPI={sEqual:"eq",sNotEqual:"ne",sStart:"sw",sContain:"ct",sFinish:"fw",sInList:"in",sIsNull:"null",sIsNotNull:"nn",sGreater:"gt",sSmaller:"lt",sBetween:"bw"};Evol.ViewFilter=Backbone.View.extend({events:{"click .evo-filters > button > .glyphicon-remove":"click_remove"},options:{fields:[],dateFormat:"mm/dd/yy",buttonLabels:!1,submitButton:!1,submitReady:!1},initialize:function(a){return this.options.fields=a.fields,this},render:function(){var a="btn btn-sm",b=this.options.buttonLabels,c=this,d=this.$el,e=['<div class="evo-filters"></div>','<button class="evo-bNew btn-primary ',a,'">',evoLang.bNewFilter,"</button>"];return this.options.submitButton&&e.push('<button class="evo-bSubmit">',evoLang.bSubmit,"</button>"),e.push('<div class="evo-editFilter"></div>','<button class="evo-bAdd btn-primary ',a,'" style="display:none;">',EvoUI.icon("ok"),"</button>",'<button class="evo-bDel ',a,'" style="display:none;">',EvoUI.icon("remove"),"</button>"),this._step=0,d.html(e.join("")),this.options.submitReady&&(this._hValues=$("<span></span>").appendTo(d)),this.options.submitButton&&(this._bSubmit=d.find(".evo-bSubmit").button({text:b}).on("click",function(a){c.$el.trigger("submit.filter")})),this._bNew=d.find(".evo-bNew").button().on("click",function(a){c._step<1&&(c._setEditorField(),c._step=1),c._bAdd.find(".ui-button-text").html(evoLang.bAddFilter)}),this._bAdd=d.find(".evo-bAdd").button().on("click",function(a){var b=c._getEditorData();c._cFilter?c._enableFilter(b,c.options.highlight):c.addFilter(b),c._removeEditor()}),this._bDel=d.find(".evo-bDel").button().on("click",function(a){c._removeEditor()}),this._editor=d.find(".evo-editFilter").on("change","#field",function(a){a.stopPropagation(),c._step>2&&c._editor.find("#value,#value2,.as-Txt").remove(),c._step>1&&(c._editor.find("#operator").remove(),c._bAdd.hide()),c._step=1;var b=$(a.currentTarget).val();if(""!==b){c._field=c._getFieldById(b);var d=c._type=c._field.type;c._setEditorOperator(),d!=EvoDico.fieldTypes.lov&&d!=EvoDico.fieldTypes.bool||c._setEditorValue()}else c._field=c._type=null}).on("change","#operator",function(a){a.stopPropagation(),c._operator=$(this).val(),c._step>2&&(c._editor.find("#value,#value2,.as-Txt").remove(),c._bAdd.hide(),c._step=2),c._setEditorValue()}).on("change keyup","#value,#value2",function(a){a.stopPropagation();var b=c._type,d=$(this).val(),e=""!==d||b==EvoDico.fieldTypes.lov||b==EvoDico.fieldTypes.bool;b==EvoDico.fieldTypes.number?e=e&&!isNaN(d):c._operator==evoAPI.sBetween&&(e=""!==c._editor.find("#value").val()&&""!==c._editor.find("#value2").val()),e?(c._bAdd.button("enable"),13==a.which&&c._bAdd.trigger("click")):c._bAdd.button("disable")}).on("click","#checkAll",function(){var a=$(this),b=a.attr("checked"),c=a.siblings();"checked"==b?c.attr("checked",b):c.removeAttr("checked")}),this._filters=d.find(".evo-filters").on("click","a",function(){c._editFilter($(this))}).on("click","a .ui-button-icon-secondary",function(a){a.stopPropagation();var b=$(this).parent();b.hasClass("ui-state-disabled")||b.fadeOut("slow",function(){b.remove(),c._triggerChange()})}),this},_getFieldById:function(a){if(!this._hash){this._hash={};for(var b=this.options.fields,c=0,d=b.length;d>c;c++)this._hash[b[c].id]=b[c]}return this._hash[a]},_removeEditor:function(){this._editor.empty(),this._bAdd.hide(),this._bDel.hide(),this._enableFilter(null,!1),this._bNew.removeClass("ui-state-active").show().focus(),this._bSubmit&&this._bSubmit.removeClass("ui-state-active").show(),this._step=0,this._field=this._type=this._operator=null},addFilter:function(a){$(['<button class="btn btn-default btn-sm">',this._htmlFilter(a),"</button>"].join("")).prependTo(this._filters).button({icons:{secondary:"ui-icon-close"}}).data("filter",a).fadeIn();return this._triggerChange(),this},removeFilter:function(a){return this._filters.children().eq(a).remove(),this._triggerChange(),this},_htmlFilter:function(a){var b=['<span class="evo-lBold">',a.field.label,"</span> ",'<span class="evo-lLight">',a.operator.label,"</span> ",'<span class="evo-lBold">',a.value.label,"</span>"];return a.operator.value==evoAPI.sBetween&&b.push('<span class="evo-lLight"> ',evoLang.opAnd," </span>",'<span class="evo-lBold">',a.value.label2,"</span>"),b.push(EvoUI.icon("remove")),b.join("")},_enableFilter:function(a,b){this._cFilter&&(this._cFilter.button("enable").removeClass("ui-state-hover ui-state-active"),a?(this._cFilter.data("filter",a).find(":first-child").html(this._htmlFilter(a)),this._cFilter=null,this._triggerChange()):this._cFilter=null)},_editFilter:function(a){var b=a.data("filter"),c=b.field.value,d=b.operator.value,e=b.value;this._enableFilter(null,!1),this._removeEditor(),this._cFilter=a.button("disable"),this._setEditorField(c),this._setEditorOperator(d),d==evoAPI.sBetween?this._setEditorValue(e.value,e.value2):this._setEditorValue(e.value),this._bAdd.find(".ui-button-text").html(evoLang.bUpdateFilter),this._step=3},_setEditorField:function(a){if(this._step<1){if(this._bNew.stop().hide(),this._bSubmit&&this._bSubmit.stop().hide(),this._bDel.show(),!this._fList){var b=this.options.fields,c=[EvoUI.inputSelectBegin("field",null,!0)];_.each(b,function(a){c.push(EvoUI.inputOption(a.id,a.label))}),c.push("</select>"),this._fList=c.join("")}$(this._fList).appendTo(this._editor).focus()}a&&(this._field=this._getFieldById(a),this._type=this._field.type,this._editor.find("#field").val(a)),this._step=1},_setEditorOperator:function(a){var b=EvoDico.fieldTypes,c=this._type;if(this._step<2){var d=[];switch(c){case b.lov:d.push(EvoUI.inputHidden("operator",evoAPI.sInList)),this._operator=evoAPI.sInList;break;case b.bool:d.push(EvoUI.inputHidden("operator",evoAPI.sEqual)),this._operator=evoAPI.sEqual;break;default:switch(d.push(EvoUI.inputSelectBegin("operator","",!0)),c){case b.date:case b.time:c==b.time?d.push(EvoUI.inputOption(evoAPI.sEqual,evoLang.sAt),EvoUI.inputOption(evoAPI.sNotEqual,evoLang.sNotAt)):d.push(EvoUI.inputOption(evoAPI.sEqual,evoLang.sOn),EvoUI.inputOption(evoAPI.sNotEqual,evoLang.sNotOn)),d.push(EvoUI.inputOptions([{id:evoAPI.sGreater,text:evoLang.sAfter},{id:evoAPI.sSmaller,text:evoLang.sBefore},{id:evoAPI.sBetween,text:evoLang.sBetween}]));break;case b.number:d.push(EvoUI.inputOptions([{id:evoAPI.sEqual,text:evoLang.sNumEqual},{id:evoAPI.sNotEqual,text:evoLang.sNumNotEqual},{id:evoAPI.sGreater,text:evoLang.sGreater},{id:evoAPI.sSmaller,text:evoLang.sSmaller}]));break;default:d.push(EvoUI.inputOptions([{id:evoAPI.sEqual,text:evoLang.sEqual},{id:evoAPI.sNotEqual,text:evoLang.sNotEqual},{id:evoAPI.sStart,text:evoLang.sStart},{id:evoAPI.sContain,text:evoLang.sContain},{id:evoAPI.sFinish,text:evoLang.sFinish}]))}d.push(EvoUI.inputOption(evoAPI.sIsNull,evoLang.sIsNull),EvoUI.inputOption(evoAPI.sIsNotNull,evoLang.sIsNotNull)),d.push("</select>")}this._editor.append(d.join(""))}a&&c!=b.lov&&(this._editor.find("#operator").val(a),this._operator=a),this._step=2},_setEditorValue:function(a,b){var c=this._editor,d=this._type,e=EvoDico.fieldTypes,f=c.find("#operator").val(),g=!1,h=!0;if(""!==f){if(d==e.lov||f!=evoAPI.sIsNull&&f!=evoAPI.sIsNotNull){if(this._step<3){var i=[];switch(g=f==evoAPI.sBetween,d){case e.lov:i.push('<span id="value">'),this._field.list.length>7&&i.push(EvoUI.inputCheckbox("checkAll",!0),'<label for="checkAll">',EvolLang.All,"</label>"),i.push(EvoUI.inputCheckboxLOV(this._field.list)),i.push("</span>");break;case e.bool:i.push('<span id="value">',EvoUI.inputRadio("value","1",evoLang.yes,"0"!=a,"value1"),EvoUI.inputRadio("value","0",evoLang.no,"0"==a,"value0"),"</span>");break;case e.date:case e.time:case e.number:var j=d;i.push('<input id="value" type="',d,'"/>'),g&&i.push('<span class="as-Txt">',evoLang.opAnd," </span>",'<input id="value2" type="',j,'"/>'),h=!1;break;default:i.push(EvoUI.inputText("value","","evo-w-")),h=!1}c.append(i.join(""))}if(a){var k=c.find("#value");switch(d){case e.lov:k.find("#"+a.split(",").join(",#")).attr("checked","checked");break;case e.bool:k.find("#value"+a).attr("checked","checked");break;default:k.val(a),h=""!==a,g&&(k.next().next().val(b),h=""!==a&&""!==b)}}else h=d==e.lov||d==e.bool}else c.append(EvoUI.inputHidden("value",""));this._bAdd.button(h?"enable":"disable").show(),this._step=3}},_getEditorData:function(){var a=this._editor,b=a.find("#field"),c=a.find("#value"),d={field:{label:b.find("option:selected").text(),value:b.val()},operator:{},value:{}},e=EvoDico.fieldTypes,f=d.operator,g=d.value;if(this._type==e.lov){var h=[],i=[];c.find("input:checked").not("#checkAll").each(function(){h.push(this.value),i.push(this.nextSibling.innerHTML)}),0===h.length?(f.label=evoLang.sIsNull,f.value=evoAPI.sIsNull,g.label=g.value=""):1==h.length?(f.label=evoLang.sEqual,f.value=evoAPI.sEqual,g.label='"'+i[0]+'"',g.value=h[0]):(f.label=evoLang.sInList,f.value=evoAPI.sInList,g.label="("+i.join(", ")+")",g.value=h.join(","))}else if(this._type==e.bool){f.label=evoLang.sEqual,f.value=evoAPI.sEqual;var j="checked"==c.find("#value1").attr("checked")?1:0;g.label=1==j?evoLang.yes:evoLang.no,g.value=j}else{var k=a.find("#operator"),l=k.val();f.label=k.find("option:selected").text(),f.value=l,l==evoAPI.sIsNull||l==evoAPI.sIsNotNull?g.label=g.value="":(this._type==e.number||this._type==e.date||this._type==e.time?g.label=c.val():g.label='"'+c.val()+'"',g.value=c.val(),l==evoAPI.sBetween&&(g.label2=g.value2=c.next().next().val()))}return d},_hiddenValue:function(a,b,c){a.push(EvoUI.inputHidden("fld-"+c,b.field.value),EvoUI.inputHidden("op-"+c,b.operator.value),EvoUI.inputHidden("val-"+c,b.value.value));var d=b.value.value2;d&&a.push(EvoUI.inputHidden("val2-"+c,d))},_setHiddenValues:function(){for(var a=this.val(),b=a.length,c=[EvoUI.inputHidden("elem",b)],d=0;b>d;d++)this._hiddenValue(c,a[d],d+1);this._hValues.html(c.join(""))},_triggerChange:function(){this.options.submitReady&&this._setHiddenValues(),this.$el.trigger("change.filter")},val:function(a){if("undefined"==typeof a){var b=[];return this._filters.find("a").each(function(){b.push($(this).data("filter"))}),b}this._filters.empty();for(var c=0,d=a.length;d>c;c++)this.addFilter(a[c]);return this._triggerChange(),this},valText:function(){var a=[];return this._filters.find("a").each(function(){a.push(this.text)}),a.join(" "+evoLang.opAnd+" ")},valUrl:function(){var a=this.val(),b=a.length,c=["filters=",b];if(1>b)return"";for(var d=0;b>d;d++){var e=a[d];c.push("&field-",d,"=",e.field.value,"&operator-",d,"=",e.operator.value,"&value-",d,"=",encodeURIComponent(e.value.value)),e.operator==evoAPI.sBetween&&c.push("&value2-",d,"=",encodeURIComponent(e.value.value2))}return c.push("&label=",encodeURIComponent(this.valText())),c.join("")},clear:function(){return this._cFilter=null,this._removeEditor(),this._filters.empty(),this._triggerChange(),this},length:function(){return this._filters.children().length},destroy:function(){var a=this.$el.off();a.find(".evo-bNew,.evo-bAdd,.evo-bDel,.evo-filters").off(),this._editor.off(),a.empty()}});var dico_field_ui={icon:"edi_fld.png",entity:"property",entities:"properties",elements:[{type:"panel",label:"Field",width:100,elements:[{id:"label",label:"Label",type:"text",cssclass:"FieldMain",cssclassview:"FieldMain",help:"Field title for the user",maxlength:100,required:!0,viewmany:!0,width:100}]},{type:"tab",label:"Definition",elements:[{type:"panel",label:"Validation",width:100,elements:[{id:"type",label:"Type",help:"User Type for the field on screen. Text, or emails can be char, varchar or nvarchar...",type:"lov",list:[{id:"text",text:"text",icon:"pix/ft-txt.gif"},{id:"textmultiline",text:"textmultiline",icon:"pix/ft-txtml.gif"},{id:"boolean",text:"boolean",icon:"pix/ft-bool.gif"},{id:"decimal",text:"decimal",icon:"pix/ft-dec.gif"},{id:"integer",text:"integer",icon:"pix/ft-int.gif"},{id:"date",text:"date",icon:"pix/ft-date.gif"},{id:"time",text:"time",icon:"pix/ft-time.gif"},{id:"datetime",text:"datetime",icon:"pix/ft-datehm.gif"},{id:"image",text:"image",icon:"pix/ft-img.gif"},{id:"lov",text:"lov",icon:"pix/ft-lov.gif"},{id:"email",text:"email",icon:"pix/ft-email.gif"},{id:"url",text:"url",icon:"pix/ft-url.gif"}],maxlength:100,required:!0,viewmany:!0,width:62},{id:"required",label:"Required",defaultvalue:!1,help:"Mandatory field",type:"boolean",maxlength:100,viewmany:!0,width:38,img:"checkr.gif"},{id:"maxlength",label:"Max. length",help:"Maximum number of characters allowed",type:"integer",maxlength:100,width:62},{id:"readonly",label:"Read only",defaultvalue:!1,help:"Users can view this field value but cannot modify it",type:"boolean",maxlength:100,width:38,img:"checkr.gif"},{id:"maxvalue",label:"Maximum value",conditions:[{visible:function(a,b){return"integer"===a.get("type")||"decimal"===a.get("type")}}],labellist:"Max.",type:"integer",maxlength:4,width:62},{id:"minvalue",label:"Minimum value",conditions:[{visible:function(a,b){return"integer"===a.get("type")||"decimal"===a.get("type")}}],labellist:"Min.",type:"integer",maxlength:4,width:38}]}]},{type:"tab",label:"Display",elements:[{type:"panel",label:"Display",width:100,elements:[{id:"position",label:"Position",help:"Integer (do not have to be consecutive)",type:"integer",maxlength:3,width:38},{id:"height",label:"Height",help:"Height in number of lines (for ''Textmultiline'' fields)",type:"integer",maxlength:3,defaultvalue:1,max:30,width:32},{id:"width",label:"Width",defaultvalue:100,help:"Relative width of the field (in percentage)",type:"integer",format:"0 '%'",maxlength:3,width:30},{id:"format",label:"Format",type:"text",help:"example '$ 0.00'",maxlength:"30",width:"38"},{id:"css",label:"CSS Field Edit",labellist:"CSS Edit",help:"Stylesheet class name for the field in edit mode.",type:"text",maxlength:20,width:32},{id:"viewmany",label:"List",help:"Field shows in lists",labellist:"List",type:"boolean",viewmany:!0,width:100}]}]},{type:"tab",id:"tab-model",label:"Model",elements:[{type:"panel",id:"map",optional:"1",label:"Model",width:100,elements:[{id:"attribute",label:"Attribute",help:"Attribute name in the Backbone model",required:!0,type:"text",maxlength:100,width:100},{id:"colpix",label:"UI name",type:"text",maxlength:100,width:100}]}]},{type:"tab",label:"User Help",elements:[{type:"panel",label:"Field Help",width:100,elements:[{etype:"field",id:"help",label:"Help",help:"Help on the field for edition",type:"textmultiline",maxlength:500,width:100,height:8}]}]}]};
var Evol=Evol||{};Evol.UI={version:"0.0.2",html:{trTableEnd:"</tr></table>",TdTrTableEnd:"</td></tr></table>",clearer:'<div class="clearfix"></div>',emptyOption:'<option value=""></option>',glyphicon:"glyphicon glyphicon-",required:'<span class="evol-required">*</span>'},fieldLabel:function(a,b){return['<div class="evol-field-label"><label for="',a,'">',b,"</label></div>"].join("")},fieldLabelSpan:function(a,b){return['<span class="evol-field-label"><label for="',a,'">',b,"</label></span>"].join("")},input:{text:function(a,b,c,d,e){var f="evo-field form-control "+(d||"")+Evol.UI.getSizeCSS(e),g=['<input type="text" id="',a,'" value="',b];if(c){if(_.each(["id","min","max","maxlength","placeholder"],function(a){void 0!==c[a]&&g.push('" ',a,'="',c[a])}),c.readonly){var h=c.readonly;(h||"1"==h)&&g.push('" ',item,'="',item)}f&&""!==f&&g.push('" class="',f)}return g.push('">'),g.join("")},textInt:function(a,b,c,d){var e=['<input class="evo-field form-control" type="number" id="',a,'" value="',b];return void 0!==c&&e.push('" min="',c),void 0!==d&&e.push('" max="',d),e.push('" maxlength="12">'),e.join("")},textM:function(a,b,c,d){return['<textarea name="',a,'" id="',a,'" class="evo-field form-control"" rows="',d,c>0?'" onKeyUp="Evol.UI.Validation.checkMaxLen(this,'+c+")":"",'">',b,"</textarea>"].join("")},textMJSON:function(a,b,c){return['<textarea rows="',c,'" class="evol-json">',_.escape(JSON.stringify(b,null," ")),"</textarea>"].join("")},myType:function(a,b,c){return['<input type="',a,'" id="',b,'" value="',c,'" class="evo-field form-control" size="15">'].join("")},date:function(a,b){return this.myType("date",a,b)},dateTime:function(a,b){return this.myType("datetime-local",a,b)},time:function(a,b){return this.myType("time",a,b)},typeFlag:function(a){return'<span class="input-group-addon">'+a+"</span>"},color:function(a,b){return['<input type="color" id="',a,'" value="',b,'" size="15">'].join("")},checkbox:function(a,b){var c=['<input type="checkbox" id="',a,'"'];return null!==b&&""!==b&&"0"!==b&&c.push(' checked="checked"'),c.push(' value="1">'),c.join("")},checkboxLOV:function(a){var b=[];for(var c in a){var d=a[c];b.push('<input type="checkbox" id="',d.id,'" value="',d.id,'"/>','<label for="',d.id,'">',d.text,"</label> ")}return b.join("")},radio:function(a,b,c,d,e){return['<label for="',e,'"><input id="',e,'" name="',a,'" type="radio" value="',b,d?'" checked="checked':"",'">',c,"</label>&nbsp;"].join("")},lov:function(a,b,c,d){var e=['<select class="evo-field form-control" id="',a,'"><option value="',b,'" selected>',c,"</option>"];return _.each(d,function(a){e.push(this.option(a.id,a.text))}),e.push("</select>"),e.join("")},img:function(a,b){return['<img id=""',a,'" src="',b,'"/>'].join("")},hidden:function(a,b){return['<input type="hidden" name="',a,'" id="',a,'" value="',b,'"/>'].join("")},hiddens:function(a){_.each(function(){a.push('<input type="hidden" name="',fID,'" id="',fID,'" value="',fV,'"/>')})},selectBegin:function(a,b,c){var d=['<select id="',a,'" class="form-control ',b,'">'];return c&&d.push(Evol.UI.html.emptyOption),d.join("")},select:function(a,b,c,d){return[this.selectBegin(a,b,c),this.options(d),"</select>"].join("")},option:function(a,b){return['<option value="',a,'">',b,"</option>"].join("")},options:function(a){var b=Evol.UI.input.option,c=[];return _.each(a,function(a){c.push(b(a.id,a.text))}),c.join("")},button:function(a,b,c){return'<button type="button" data-id="'+a+'" class="btn'+(c?" "+c:"")+'">'+b+"</button>"}},link:function(a,b,c){return['<a class="evo-field" href="',c,'" id="',a,'">',b,"</a>"].join("")},linkEmail:function(a,b,c){return Evol.UI.link(a,b,c?"mailto:"+c:"")},icon:function(a,b){return['<i class="',b?b+" ":"",Evol.UI.html.glyphicon,a,'"></i>'].join("")},iconCustomize:function(a,b){return Evol.UI.iconId(a,b,"wrench")},iconId:function(a,b,c){return['<i class="',Evol.UI.html.glyphicon,c,'" data-id="',a,'" data-type="',b,'"></i>'].join("")},HTMLPanelLabel:function(a){return['<div class="panel-heading">',Evol.UI.icon("chevron-up","evol-title-toggle"),'<h3 class="panel-title">',a,"</h3></div>"].join("")},HTMLEmptyPanel:function(a,b,c){return'<div class="'+b+" panel panel-"+c+'" data-id="'+a+'"></div>'},HTMLMsg:function(a,b,c,d){return['<div data-id="msg" class="alert alert-',c||"info",d?' alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>':'">',"<strong>",a,"</strong> ",b,"</div>"].join("")},formatDate:function(a){return a},formatTime:function(a){return a},formatDateTime:function(a){if(void 0!==a&&""!==a){var b=a.split("-");if(b.length>1)return b[1]+"/"+b[2]+"/"+b[0]}return""},getSizeCSS:function(a){switch(a){case"S":return" input-sm";case"L":return" input-lg"}return""},insertCollection:function(a,b){0===a.length&&_.each(b,function(b){a.create(b)})},capFirstLetter:function(a){return a&&a.length>0?a.substring(0,1).toUpperCase()+a.substring(1):""},trim:function(a){return a?a.replace(/^\s+|\s+$/g,""):""},setVisible:function(a,b){b?a.show():a.hide()}},Evol.UI.Charts={URL:"http://chart.apis.google.com/chart",_HTML:function(a,b,c){return['<div class="evol-chart-holder panel ',c,'"><label class="evol-chart-title">',a,'</label><img src="',b,'"><br></div>'].join("")},Pie:function(a,b,c,d){var e=[this.URL,"?chd=t:",b.join(","),"&amp;chl=",c.join("|"),"&amp;cht=p&amp;chds=0,20&amp;chs=360x200"].join("");return this._HTML(a,e,d||"panel-default")},Bars:function(a,b,c,d){var e=_.max(b),f=[this.URL,"?chbh=a&amp;chs=350x200&cht=bvg&chco=3a87ad,d9edf7&chds=0,",e,"&amp;chd=t:",b.join("|"),"&amp;chp=0.05&amp;chts=676767,10.5&amp;chdl=",c.join("|")].join("");return this._HTML(a,f,d)}},Evol.UI.Validation={checkMaxLen:function(a,b){a.value.length>b&&(a.value=a.value.substring(0,b-1))},checkNum:function(a,b){var c,d=a.value;if("i"==b.substring(0,1))c=parseInt(d,10);else{var e=Evol.i18n.LOCALE;("FR"==e||"DA"==e)&&(d=d.replace(",",".")),c=parseFloat(d)}isNaN(c)?a.value="":d!=c&&(a.value=c)},setValidationFlags:function(a,b){var c=a.find(".text-danger");c.length?c.html(b):a.append('<p class="text-danger">'+b+"</p>"),a.addClass("has-error")},checkFields:function(a,b,c){function d(){var a=Evol.Dico.fieldTypes,b=Evol.UI.trim(n.val());if(""!==b)switch(m.type){case a.integer:case a.email:k[m.type].test(b)||h.setValidationFlags(n.parent(),g(j[m.type]));break;case a.dec:var c=k[m.type+Evol.i18n.LOCALE];null===c&&(c=k[m.type+"EN"]),c.test(b)||h.setValidationFlags(n.parent(),g(j[m.type]));break;case a.date:case a.datetime:case a.time:""===b||_.isDate(new Date(b))||h.setValidationFlags(n.parent(),g(j[m.type]))}}function e(a){var b,c=a.tagName;return b="SELECT"==c&&a.get(0).selectedIndex>-1?"0"==f.options[a.get(0).selectedIndex].value:""===Evol.UI.trim(a.val())}function g(a,b){var c=a.replace("{0}",m.label);return null!==b&&(c=c.replace("{1}",b)),i.push(c),c}var h=this,i=[],j=Evol.i18n.validation,k={email:/^[\w\.\-]+@[\w\.\-]+\.[\w\.\-]+$/,integer:/^-?\d+$/,decimalEN:/^\d+(\.\d+)?$/,decimalFR:/^\d+(\,\d+)?$/,decimalDA:/^\d+(\,\d+)?$/};for(var l in b){var m=b[l],n=a.find("#"+c+"-"+m.id).eq(0),o="html"==m.type;if(o&&n.val(nicEditors.findEditor(f.id).getContent()),n.length>0){var p,q,r=!0;if(m.required>0?e(n,o)?(p=n.parent(),q=g(j.empty),h.setValidationFlags(p,q),r=!1):(n.parent().removeClass("control-group error").find(".evol-warn-error").remove(),d()):d(),null!==m.regex&&void 0!==m.regex){var s=new RegExp(m.regex);n.val().match(s)||(p=n.parent(),q=g(j.regex,m.label),h.setValidationFlags(n.parent(),q))}if(r){var t=Evol.UI.trim(n.val());""!==t&&(null!==m.max&&parseFloat(t)>m.max&&h.setValidationFlags(n.parent(),g(j.max,m.max)),null!==m.min&&parseFloat(t)<m.min&&h.setValidationFlags(n.parent(),g(j.min,m.min)))}}}return i.length>0?[j.intro,"<ul><li>",i.join("<li>"),"</li></ul>"].join(""):""}};var Evol=Evol||{};Evol.i18n={LOCALE:"EN",getLabel:function(a,b,c){var d;if(a.indexOf(".")>-1){var e=a.split(".");d=this[e[0]][e[1]]}else d=this[a];return b&&(d=d.replace("{0}",b),c&&(d=d.replace("{1}",c))),d},View:"View",Edit:"Edit",New:"New",NewEntity:"New {0}",NewUpload:"New Upload",Selections:"Selections",Selection:"Selection",Export:"Export",SearchRes:"Search Result",Delete:"Delete",All:"All",DeleteEntity:'Delete {0} "{1}"?',Back2SearchResults:"Back to search results",nodata:"No data available.",nopix:"No picture.",nochart:"No charts available.",badchart:"The data structure doesn't allow for auto-generated charts.",Save:"Save",SaveAdd:"Save and Add Another",Cancel:"Cancel",NoChange:"No Change",NoX:"No {0}",status:{added:'New {0} "{1}" added.',updated:'{0} "{1}" updated.',deleted:'{0} "{1}" removed.'},validation:{intro:"You are not finished yet:",empty:'"{0}" must have a value.',email:'"{0}" must be a valid email.',integer:'"{0}" must only use numbers.',decimal:'"{0}" must be a valid decimal numbers.',date:'"{0}" must be a valid date, format must be "MM/DD/YYYY" like "12/24/2005".',datetime:'"{0}" must be a valid date/time, format must be "MM/DD/YYYY hh:mm am/pm" like "12/24/2005 10:30 am".',time:'"{0}" must be a valid date/time, format must be "hh:mm am/pm" like "10:30 am".',max:'"{0}" must be smaller or equal to {1}.',min:'"{0}" must be greater or equal to {1}.',regex:'The value "{0}" is not of the expected format.'},charts:{aByB:"{0} by {1}",aB:"{0}: {1}"},"export":{ExportEntity:"Export {0}",ExportEntities:"Export {0}",ExportHeader:"Header",ExportSeparator:"Separator",ExportFirstLine:"First line for field names",ExportFormat:"Export format",ExportFields:"Fields to include in the export",IDkey:"ID (Primary Key)",AllFields:"Show all fields",ExportFormats:"Comma separated (CSV, TXT, XLS...)-HTML-SQL Insert Statements (SQL)-Tab separated values (TXT)-XML-Javascript Object Notation (JSON)",xpXMLroot:"Element name",xpSQL:"SQL Options",xpSQLTable:"Table name",xpSQLTrans:"Inside transaction",xpSQLId:"Enable identity insert",DownloadEntity:"Download {0}"},filters:{sEqual:"equals",sNotEqual:"not equal",sStart:"starts with",sContain:"contains",sFinish:"finishes with",sInList:"any of",sIsNull:"is empty",sIsNotNull:"is not empty",sBefore:"before",sAfter:"after",sNumEqual:"&#61;",sNumNotEqual:"!&#61;",sGreater:"&#62;",sSmaller:"&#60;",sOn:"on",sNotOn:"not on",sAt:"at",sNotAt:"not at",sBetween:"between",opAnd:"and",yes:"Yes",no:"No",bNewFilter:"New filter",bAddFilter:"Add filter",bUpdateFilter:"Update filter",bSubmit:"Submit",bCancel:"Cancel"}};var Evol=Evol||{};Evol.Dico={fieldTypes:{text:"text",txtm:"textmultiline",bool:"boolean",dec:"decimal",integer:"integer",date:"date",time:"time",datetime:"datetime",pix:"image",lov:"lov",money:"money",email:"email",url:"url",color:"color",hidden:"hidden",tag:"tag"},getFields:function(a,b){function c(a){a&&a.elements&&a.elements.length>0?_.each(a.elements,function(a){"panel-list"!=a.type&&c(a)}):d.push(a)}var d=[];return c(a),_.isFunction(b)&&(d=_.filter(d,b)),d},getSubCollecs:function(a){function b(a){"panel-list"===a.type?c.push(a):"panel"!==a.type&&a.elements&&a.elements.length>0?_.each(a.elements,function(a){"panel-list"===a.type?c.push(a):"panel"!==a.type&&b(a)}):c.push(a)}var c=[];return b(a),c},lovText:function(a,b,c){if("list"in b&&b.list.length>0){b.id in a||(a[b.id]={});var d=a[b.id];if(c in d)return d[c];var e=_.find(b.list,function(a){return a.id===c});if(e){var f=e.text;return e.icon&&(f='<img src="'+e.icon+'"> '+f),d[c]=f,f}}return""},isTypeDateOrTime:function(a){return a==EvoDico.fieldTypes.datetime||EvoDico.fieldTypes.date||a==EvoDico.fieldTypes.time},showDesigner:function(a,b,c){var d,e=$('<div class="evol-des-'+b+'"></div>');switch(b){case"field":d=dico_field_ui}return c.closest(".evol-fld").after(e),vw=new Evol.ViewOne.Edit({model:null,uiModel:d,defaultView:"edit",el:e,style:"panel-primary",size:"S",button_addAnother:!1}).render(),e.on("click","button#save,button#cancel",function(){e.remove()}),this},bbComparator:function(a){return function(b,c){return b.get(a)>c.get(a)}},bbComparatorText:function(a){return function(b,c){return(b.get(a)||"").localeCompare(c.get(a)||"")}}};var Evol=Evol||{};Evol.ViewMany=Backbone.View.extend({cardinality:"n",_hashLov:{},options:{style:"panel-info",pageSize:20,titleSelector:"#title",selectable:!0},events:{"click .evol-nav-id":"click_navigate","click .evol-sort-icons > i":"click_sort","click .button.edit":"click_pagination","click .evol-field-label .glyphicon-wrench":"click_customize"},initialize:function(a){var b=this;this.options=_.extend(this.options,a),this._filter=[],this.collection&&this.collection.on("change",function(){b.render()}),this._custOn=!1},render:function(){var a=this.collection.models;if(this.collection.length){if(this._filter.length){var b=this;a=a.filter(function(a){for(var c=b._filter,d=!0,e=0,f=c.length;f>e&&d;e++){var g=c[e],h=g.value.value,i=a.get(g.field.value);switch(void 0===i&&(i=""),g.operator.value){case"eq":d=h===i;break;case"ne":d=h!==i;break;case"sw":d=0===i.indexOf(h);break;case"ct":d=i.indexOf(h)>-1;break;case"fw":d=i.indexOf(h)===i.length-h.length;break;case"null":d=""===i||void 0===i;break;case"nn":d=""!==i||void 0!==i;break;case"in":d=_.contains(h.split(","),i);break;case 1:d=i;break;case 0:d=!i}}return d})}this._render(a)}else this.$el.html(Evol.UI.HTMLMsg(Evol.i18n.nodata,"","info"));return this._updateTitle(),this},_render:function(){alert("_render must be overwritten")},customize:function(){var a=this.$("th > span");return this._custOn?a.find("i").remove():a.append(Evol.UI.iconCustomize("id","field")),this._custOn=!this._custOn,this},setModel:function(a){return a&&a.collection&&(this.collection=a.collection),this.render(),this},setCollection:function(a){return this.collection=a,this.render(),this},getCollection:function(){return this.collection},setFilter:function(a){return this._filter=a,this},getFilter:function(){return this._filter},_updateTitle:function(){$(this.options.titleSelector).html(this.getTitle())},getTitle:function(){return Evol.UI.capFirstLetter(this.options.uiModel.entities)},getFields:function(){if(!this._fields){this._fields=Evol.Dico.getFields(this.options.uiModel,function(a){return a.viewmany}),this._fieldHash={};var a=this;_.each(this._fields,function(b){a._fieldHash[b.id]=b})}return this._fields},getField:function(a){return this._fieldHash[a]},_HTMLField:function(a,b){var c=Evol.Dico.fieldTypes;switch(a.type){case c.bool:if("true"===b||"1"==b)return Evol.UI.icon("ok");break;case c.lov:if(""!==b)return Evol.Dico.lovText(this._hashLov,a,b);break;case c.date:case c.time:case c.datetime:return Evol.UI.formatDateTime(b);case c.pix:if(b.length)return Evol.UI.input.img(a.id,b);break;case c.money:var d=parseFloat(b);if(!isNaN(d))return"$"+d.toFixed(2);break;default:return b}return""},_paginationSummaryHTML:function(a,b,c,d,e){var f,g=a*b+1;if(1>a){if(0===c)return c+" "+e;if(1===c)return c+" "+d;f=_.min([b,c])}else f=_.min([g+b,c]);return["<p>",g,"-",f," of ",c," ",e,"</p>"].join("")},_paginationHTML:function(a,b,c){var d=a*b+1,e=parseInt(c/b,10),f=e>5?5:e,g=['<ul class="pagination pagination-sm">'];a>0&&g.push('<li data-id="prev"><a href="#">&laquo;</a></li>');for(var h=d;f>h;h++)g.push('<li data-id="',h,'"><a href="#">',h,"</a></li>");return c>(a+1)*b&&g.push('<li data-id="next"><a href="#">&raquo;</a></li>'),g.push("</ul>"),g.join("")},sortList:function(a,b){var c=this.collection,d=Evol.Dico.fieldTypes;void 0!==c&&(c.comparator=a.type==d.text||a.type==d.txtm||a.type==d.email?Evol.Dico.bbComparatorText(a.id):Evol.Dico.bbComparator(a.id),c.sort(),b&&c.models.reverse(),this.renderBody?this.renderBody(c.models):this.render(),this.$el.trigger("list.sort",{id:a.id,direction:b?"down":"up"}))},click_navigate:function(a){var b=$(a.currentTarget),c="list"===this.options.mode?"tr":"div";a.type="list.navigate",this.$el.trigger(a,{id:b.closest(c).data("id")})},click_sort:function(a){var b=$(a.currentTarget),c=b.parent().data("fid"),d=this.getField(c),e=b.attr("class").indexOf("-down")>0;this.sortList(d,e),b.addClass("evol-last-sort")},click_pagination:function(a){this.$el.trigger("list.paginate",{id:$(a.currentTarget).closest("li").data("id")})},click_customize:function(a){var b=$(a.currentTarget),c=b.data("id"),d=b.data("type");Evol.Dico.showDesigner(c,d,b),this.$el.trigger(d+".customize",{id:c,type:d})}});var Evol=Evol||{};Evol.ViewMany.Cards=Evol.ViewMany.extend({viewName:"cards",customize:function(){var a=this.$("h4 > a.evol-nav-id");return this._custOn?(a.find("i").remove(),this._custOn=!1):(a.append(Evol.UI.iconCustomize("id","field")),this._custOn=!0),this},_render:function(a){var b=[];if(a&&a.length>0){var c=this.options,d=c.uiModel,e=c.pageSize||50,f=this._paginationSummaryHTML(0,e,a.length,d.entity,d.entities);b.push('<div class="evol-many-cards">'),this._HTMLcards(b,this.getFields(),e,d.icon),b.push(f,this._paginationHTML(0,e,a.length),"</div>")}else b.push(Evol.UI.HTMLMsg(Evol.i18n.nodata,"","info"));return this.$el.html(b.join("")),this},_HTMLcards:function(a,b,c,d){var e=this.collection.models,f=_.min([e.length,c]);if(f>0){for(var g=0;f>g;g++){a.push('<div class="panel ',this.options.style,'">');for(var h=0;h<b.length;h++){var i=b[h],j=e[g],k=j.get(i.id);0===h?(a.push('<div data-id="',j.id,'">','<h4><a href="#" id="fg-',i.id,'" class="evol-nav-id">'),d&&a.push('<img class="evol-table-icon" src="pix/',d,'">'),a.push(this._HTMLField(i,k),"</a></h4></div>")):a.push("<div>",this._HTMLField(i,k),"</div>")}a.push("</div>")}a.push(Evol.UI.html.clearer)}else a.push(Evol.UI.HTMLMsg(Evol.i18n.nodata,"","info"))}});var Evol=Evol||{};Evol.ViewMany.Charts=Evol.ViewMany.extend({viewName:"chart",events:{"click .evol-field-label .glyphicon-wrench":"click_customize"},render:function(){var a=[];return this.collection&&this.collection.length>0?(a.push('<div class="evol-many-',this.viewName,'">'),this._HTMLcharts(a,this.options.style),a.push("</div>")):a.push(Evol.UI.HTMLMsg(Evol.i18n.nodata,"","info")),this._updateTitle(),this.$el.html(a.join("")),this},_HTMLcharts:function(a,b){var c=this,d=Evol.UI,e=Evol.Dico,f=e.fieldTypes,g=this.options.uiModel,h=this.collection.models,i=e.getFields(g,function(a){return a.type==f.lov||a.type==f.bool||a.type==f.integer});i&&i.length?_.each(i,function(i){var j=_.countBy(h,function(a){return a.get(i.id)}),k=j,l=[],m=[];for(var n in k){var o=k[n];l.push(o),i.type==f.lov?m.push(e.lovText(c._hashLov,i,n)+" ("+o+")"):m.push(n+" ("+o+")")}var p=d.capFirstLetter(g.entities);i.type==f.lov?a.push(d.Charts.Pie(Evol.i18n.getLabel("charts.aByB",p,i.label),l,m,b)):a.push(d.Charts.Bars(Evol.i18n.getLabel("charts.aB",p,i.label),l,m,b))}):a.push(d.HTMLMsg(Evol.i18n.nochart,Evol.i18n.nochart)),a.push(d.html.clearer)}});var Evol=Evol||{};Evol.ViewMany.List=Evol.ViewMany.extend({viewName:"list",options:{style:"panel-info",pageSize:20,selectable:!0},_render:function(a){var b=[],c=this.getFields(),d=this.options,e=d.uiModel,f=d.pageSize||50,g=this._paginationSummaryHTML(0,f,a.length,e.entity,e.entities);this._models=a,b.push('<div class="evol-many-list">','<table class="table table-bordered table-hover"><thead>');for(var h=0;h<c.length;h++)this._HTMLlistHeader(b,c[h]);b.push("</thead><tbody>"),this._HTMLlistBody(b,c,f,e.icon),b.push("</tbody></table>",g,this._paginationHTML(0,f,a.length),"</div>"),this.$el.html(b.join(""))},renderBody:function(){var a=[],b=this.getFields(),c=this.options,d=c.uiModel,e=c.pageSize||50;this._HTMLlistBody(a,b,e,d.icon),this.$(".table > tbody").html(a.join(""))},_HTMLlistBody:function(a,b,c,d){var e=this._models,f=_.min([e.length,c]);if(f>0)for(var g=0;f>g;g++)this._HTMLlistRow(a,b,e[g],d)},_HTMLlistRow:function(a,b,c,d){a.push('<tr data-id="',c.cid,'">');for(var e=0;e<b.length;e++){var f=b[e],g=c.escape(f.id);a.push("<td>"),0===e&&(a.push('<a href="javascript:void(0)" id="fv-',f.id,'" class="evol-nav-id">'),_.isFunction(d)?a.push('<img class="evol-table-icon" src="pix/',d(c),'">'):""!==d&&a.push('<img class="evol-table-icon" src="pix/',d,'">'),""===g&&(g="("+c.id+")")),a.push(this._HTMLField(f,g)),0===e&&a.push("</a>"),a.push("</td>")}a.push("</tr>")},_HTMLlistHeader:function(a,b){a.push('<th><span id="',b.id,'-lbl">',b.labellist||b.label,'<span class="evol-sort-icons" data-fid="',b.id,'">',Evol.UI.icon("chevron-up"),Evol.UI.icon("chevron-down"),"</span></span></th>")}});var Evol=Evol||{};Evol.ViewOne=Backbone.View.extend({events:{"click .evol-buttons > button":"click_button","click .evol-title-toggle":"click_toggle","click ul.evol-tabs > li > a":"click_tab","click label > .glyphicon-question-sign":"click_help","click .evol-field-label .glyphicon-wrench":"click_customize"},cardinality:"1",options:{button_addAnother:!1,style:"panel-info",titleSelector:"#title"},initialize:function(a){var b=this;_.extend(this.options,a),this._uTitle=void 0!==this.options.titleSelector&&""!==this.options.titleSelector,this.model&&this.model.on("change",function(a){b.setModel(a)})},render:function(){var a=this.options.mode,b=[];return this.renderEdit(b,a),this.$el.html(b.join("")),this.setData(this.model),this.custOn=!1,this},getFields:function(){if(!this._fields){this._fields=Evol.Dico.getFields(this.options.uiModel,this.getFieldsCondition),this._fieldHash={};var a=this;_.each(this._fields,function(b){a._fieldHash[b.id]=b})}return this._fields},getSubCollecs:function(){return this._subCollecs||(this._subCollecs=Evol.Dico.getSubCollecs(this.options.uiModel)),this._subCollecs},setModel:function(a){return this.model=a,this.clearMessages().setData(a)},getModel:function(){return this.model},setUIModel:function(a){this.options.uiModel=a;var b=this.getData();return this.render().setData(b)},getUIModel:function(){return this.options.uiModel},modelUpdate:function(a){var b=this;_.each(a.changed,function(a,c){b.setFieldValue(c,a)})},getTitle:function(){if(this.model){var a=this.options.uiModel.leadfield;return _.isFunction(a)?a(this.model):this.model.get(a)}return Evol.UI.capFirstLetter(this.options.uiModel.entity)},getData:function(){var a=this,b={};return _.each(this.getFields(),function(c){b[c.id]=a.getFieldValue(c)}),b},setData:function(a){if(void 0!==a&&null!==a){var b,c,d=this.getFields(),e=this,f=Evol.Dico.fieldTypes,g="#"+e.prefix+"-",h=this.getSubCollecs();_.each(d,function(d){if(b=e.$(g+d.id),c=a.get(d.id),a)switch(d.type){case f.lov:b.children().removeAttr("selected").filter("[value="+c+"]").attr("selected",!0);break;case f.bool:b.prop("checked",c);break;case f.pix:var h=""!==c?'<img src="'+c+'" class="img-thumbnail">':'<p class="">'+Evol.i18n.nopix+"</p>";b.val(c).prev().remove(),b.before(h);break;default:b.val(c)}}),h&&h.length>0&&_.each(h,function(a){var b=[];e._renderPanelListBody(b,a),e.$('[data-pid="'+a.id+'"] tbody').html(b.join(""))})}return this._updateTitle()},clear:function(){var a,b=this.getFields(),c=this,d="#"+c.prefix+"-";return this.clearMessages(),_.each(b,function(b){switch(a=c.$(d+b.id),b.type){case"boolean":a.prop("checked",b.defaultvalue||"");break;default:a.val(b.defaultvalue||"")}}),this},setFieldValue:function(a,b){return this.$("#"+this.fieldViewId(a)).val(b),this},getFieldValue:function(a){var b=this.$("#"+this.fieldViewId(a.id));switch(a.type){case Evol.Dico.fieldTypes.bool:return b.prop("checked");case Evol.Dico.fieldTypes.integer:return parseInt(b.val(),10);case Evol.Dico.fieldTypes.decimal:case Evol.Dico.fieldTypes.money:return parseFloat(b.val());default:return b.val()}},showTab:function(a){var b=this.$(a);return b.length>0&&(b.siblings(".tab-pane").hide(),b.show()),b=this.$('.evol-tabs > li a[href="'+a+'"]').parent(),b.length>0&&(b.siblings("li").removeClass("active"),b.addClass("active")),this.$el.trigger("tab.show"),this},_renderButtons:function(a,b){var c=Evol.UI.getSizeCSS(this.options.size);a.push(Evol.UI.html.clearer,'<div class="evol-buttons">',Evol.UI.input.button("cancel",Evol.i18n.Cancel,"btn-default"+c),Evol.UI.input.button("save",Evol.i18n.Save,"btn-primary"+c)),this.options.button_addAnother&&"json"!==b&&a.push(Evol.UI.input.button("save-add",Evol.i18n.SaveAdd,"btn-default"+c)),a.push("</div>")},renderEdit:function(a,b){var c=-1,d=-1,e=this.options,f=e.uiModel.elements;if("mini"===b){var g=Evol.Dico.getFields(e.uiModel,function(a){return a.searchlist||a.required||a.mini},e.mode),h={type:"panel","class":"evol-mini-holder",label:Evol.UI.capFirstLetter(e.uiModel.entity),width:100,elements:g};this.renderPanel(a,h,"evo-one-mini",b)}else{a.push('<div class="evo-one-',b,'">');for(var i=0,j=f.length;j>i;i++){var k=f[i];switch(k.type){case"tab":d>0&&(a.push("</div>"),d=-1),0>c&&(a.push(Evol.UI.html.clearer),this.renderTabs(a,f),a.push('<div class="tab-content">')),c++,a.push('<div id="evol-tab-',i,'" class="tab-pane',1===i?' active">':'">'),this.renderTab(a,k,b),c==j-1&&a.push("</div>");break;case"panel":0>d&&(a.push('<div class="evol-pnls">'),d=1),this.renderPanel(a,k,"p-"+k.id,b);break;case"panel-list":this._hasSubCollec=!0,0>d&&(a.push(""),d=1),this.renderPanelList(a,k,b)}}d>0&&a.push("</div>"),a.push("</div>")}this._renderButtons(a,b)},renderTabs:function(a,b){var c=!0;a.push('<ul class="nav nav-tabs evol-tabs">'),_.each(b,function(b,d){"tab"==b.type&&(c?(a.push('<li class="active">'),c=!1):a.push("<li>"),a.push('<a href="#evol-tab-',d,'">',b.label,"</a></li>"))}),a.push("</ul>")},renderTab:function(a,b,c){var d=this;a.push('<div class="evol-pnls">'),_.each(b.elements,function(b,e){"panel-list"===b.type?d.renderPanelList(a,b,c):d.renderPanel(a,b,b.id||"pl-"+e,c)}),a.push(Evol.UI.html.clearer,"</div></div>")},renderPanel:function(a,b,c,d){var e=this;a.push('<div data-p-width="',b.width,'" class="evol-pnl'),"mini"===d?a.push(" w-100 ",b.class||"",'">'):a.push(' pull-left" style="width:',b.width,'%">'),a.push('<div class="panel ',this.options.style,'">',Evol.UI.HTMLPanelLabel(b.label,c,"PanelLabel"),'<fieldset data-pid="',c,'">'),"mini"===d?_.each(b.elements,function(b){a.push('<div class="pull-left evol-fld w-100">'),e.renderField(a,b,d),a.push("</div>")}):_.each(b.elements,function(b){a.push('<div style="width:',parseInt(b.width,10),'%" class="pull-left evol-fld">'),e.renderField(a,b,d),a.push("</div>")}),a.push("</fieldset></div></div>")},renderPanelList:function(a,b,c){a.push('<div style="width:',b.width,'%" class="evol-pnl pull-left" data-pid="',b.id,'">','<div class="panel ',this.options.style,'">',Evol.UI.HTMLPanelLabel(b.label,b.id,"PanelLabel"),'<table class="table"><thead><tr>'),_.each(b.elements,function(b){a.push("<th>",b.label,"</th>")}),a.push("</tr></thead><tbody>"),this._renderPanelListBody(a,b,c),a.push("</tbody></table></div></div>")},_renderPanelListBody:function(a,b){var c=this.model.get(b.attr);c&&c.length>0?_.each(c,function(c){a.push("<tr>"),_.each(b.elements,function(b){c[b.id]?a.push("<td>",c[b.id],"</td>"):a.push("<td></td>")}),a.push("</tr>")}):a.push('<tr><td colspan="',b.elements.length,'" class="evol-pl-nodata">',Evol.i18n.nodata,"</td></tr>")},renderField:function(a,b,c){var d,e,f=Evol.UI,g=Evol.Dico.fieldTypes,h=this.fieldViewId(b.id),i=this.options.size;if(this.model&&this.model.has(b.id)&&(d="new"!==c?this.model.get(b.id):b.defaultvalue||""),"mini"===c?(e=b.width,b.width=100,a.push('<div class="evol-mini-label">'),this.renderFieldLabel(a,b,c),a.push('</div><div class="evol-mini-content">')):this.renderFieldLabel(a,b,c),b.readonly>0)a.push('<div id="',h,'" class="FieldReadOnly">',d,"&nbsp;</div>");else switch(b.type){case g.text:a.push(f.input.text(h,d,b,null,i));break;case g.email:"view"===c?a.push(f.link(h,d,"mailto:"+HttpUtility.HtmlEncode(d))):a.push('<div class="input-group">',f.input.typeFlag("@"),f.input.text(h,d,b.maxlength),"</div>");break;case g.url:"view"===c?a.push(f.link(h,d,HttpUtility.HtmlEncode(d))):a.push(f.input.text(h,d,b.maxlength));break;case g.integer:case g.dec:a.push(f.input.textInt(h,d));break;case g.money:a.push('<div class="input-group">',f.input.typeFlag("$"),f.input.textInt(h,d),"</div>");break;case g.bool:a.push(f.input.checkbox(h,d));break;case g.txtm:case g.html:null===b.height?b.height=5:(fHeight=parseInt(b.height,10),1>fHeight&&(b.height=5)),a.push(f.input.textM(h,d,b.maxlength,b.height));break;case g.date:a.push(f.input.date(h,d));break;case g.datetime:a.push(f.input.dateTime(h,d));break;case g.time:a.push(f.input.time(h,d));break;case g.color:a.push(f.input.color(h,d));break;case g.lov:a.push(f.input.select(h,"",!0,b.list));break;case g.integer:a.push(f.input.textInt(h,d,b.max,b.min));break;case g.pix:""!==d?a.push('<img src="',d,'" class="img-thumbnail">'):a.push('<p class="">',Evol.i18n.nopix,"</p>"),a.push(f.input.text(h,d,b,null,i))}"mini"===c&&(a.push("</div>"),b.width=e)},renderFieldLabel:function(a,b,c){a.push('<div class="evol-field-label" id="',b.id,'-lbl"><label class="control-label" for="',b.id,'">',b.label),"view"!=c&&b.required&&a.push(Evol.UI.html.required),b.help&&""!==b.help&&a.push(Evol.UI.icon("question-sign","")),a.push("</label></div>")},_updateTitle:function(a){if(this._uTitle){var b=this.options,c=b.titleSelector;if(c&&""!==c){var d,e=b.uiModel.leadfield;return d=a?a:void 0!==e&&""!==e?this.getTitle():Evol.UI.capFirstLetter(b.uiModel.entities),$(c).text(d),this._uTitle=!0,this}this._uTitle=!1}return this},validate:function(){var a=this.getFields();return this.clearMessages(),_.isArray(a)?(this.$el.trigger("validate"),Evol.UI.Validation.checkFields(this.$el,a,this.prefix)):!1},clearErrors:function(){return this.$(".control-group.error").removeClass("control-group error"),this.$(".has-error").removeClass("has-error"),this.$(".text-danger").remove(),this},fieldViewId:function(a){return this.prefix+"-"+a},customize:function(){var a=".evol-field-label > label",b=".evol-pnl .panel-title";return this.custOn?(this.$(a+">i, "+b+">i").remove(),this.custOn=!1):(_.each(this.$(a),function(a){var b=$(a),c=b.attr("for");b.append(Evol.UI.iconCustomize(c,"field"))}),this.$(b).append(Evol.UI.iconCustomize("id","panel")),this.custOn=!0),this},showHelp:function(a,b,c){var d=Evol.Dico.getFields(this.options.uiModel),e=_.findWhere(d,{id:a});if(e||e.help){var f=c.closest(".evol-fld"),g=f.find(".help-block");if(g.length>0)g.slideUp(300,function(){g.remove()});else{var h=$('<span class="help-block">'+_.escape(e.help)+"</span>").hide();f.append(h),h.slideDown(300)}}return this},clearMessages:function(){return this.clearErrors()},click_button:function(a){var b=$(a.currentTarget).data("id");a.stopImmediatePropagation(),this.$el.trigger("action",b)},click_toggle:function(a){var b,c=$(a.target),d=c.closest(".panel-heading").next(),e=d.data("expState"),f="glyphicon-chevron-up",g="glyphicon-chevron-down";a.preventDefault(),a.stopImmediatePropagation(),a.shiftKey?(c=this.$(".evol-title-toggle"),b="down"===e?g:f,c=this.$(".evol-title-toggle."+b).trigger("click")):"down"===e?(c.closest(".panel").css("height",""),d.slideDown(400).data("expState","up"),c.addClass(f).removeClass(g)):(d.slideUp(400,function(){c.closest(".panel").css("height","40px")}).data("expState","down"),c.removeClass(f).addClass(g)),this.$el.trigger("panel.toggle")},click_tab:function(a){var b=a.target.href,c=b.substring(b.indexOf("#"));a.stopImmediatePropagation(),a.preventDefault(),a.shiftKey?this.$(".tab-content > div").show():this.showTab(c)},click_help:function(a){var b=$(a.currentTarget),c=b.closest("label").attr("for"),d=b.data("type");a.stopImmediatePropagation(),this.showHelp(c,d,b),this.$el.trigger(d+".help",{id:c})},click_customize:function(a){var b=$(a.currentTarget),c=b.data("id"),d=b.data("type");a.stopImmediatePropagation(),Evol.Dico.showDesigner(c,d,b),this.$el.trigger(d+".customize",{id:c,type:d})}});var Evol=Evol||{};Evol.ViewOne.Edit=Evol.ViewOne.extend({viewName:"edit",prefix:"oe",render:function(){var a=[];return this.renderEdit(a),this.$el.html(a.join("")),this.setData(this.model),this.custOn=!1,this}});var Evol=Evol||{};Evol.ViewOne.JSON=Evol.ViewOne.extend({events:{"click > .evol-buttons > button":"click_button"},viewName:"json",render:function(){var a=[];if(this.model){var b=JSON.stringify(this.model,null,2);a.push(Evol.UI.input.textMJSON("",b,10))}return this._renderButtons(a,"json"),this.$el.html(a.join("")),this.setData(this.model),this.custOn=!1,this},getData:function(){var a=this.$el.children("textarea").val();
return $.parseJSON(a)},setData:function(a){return this.$el.children("textarea").val(JSON.stringify(a,null,2)),this._updateTitle()},clear:function(){return this.$el.children("textarea").val(""),this}});var Evol=Evol||{};Evol.ViewOne.Mini=Evol.ViewOne.extend({events:{"click > .evol-buttons > button":"click_button","click .evol-title-toggle":"click_toggle","click label > .glyphicon-question-sign":"click_help"},viewName:"mini",prefix:"om",getFieldsCondition:function(a){return a.required||a.viewmany||a.viewmini},render:function(){var a=this.options.mode,b=[];return this._renderEdit(b,a),this.$el.html(b.join("")),this.setData(this.model),this.custOn=!1,this},_renderEdit:function(a,b){var c=this.options,d=this.getFields(),e={type:"panel","class":"evol-mini-holder",label:Evol.UI.capFirstLetter(c.uiModel.entity),width:100,elements:d};this.renderPanel(a,e,"evol-one-mini",b),this._renderButtons(a,b)}});var Evol=Evol||{};Evol.ViewToolbar=Backbone.View.extend({events:{"click .nav a":"click_toolbar","list.navigate div":"click_navigate","click #XP":"click_download","action > div":"action_view"},options:{toolbar:!0,defaultView:"list",style:"panel-info",display:"tooltip",titleSelector:"#title",buttons:{edit:!0,mini:!0,json:!0,list:!0,cards:!0,charts:!0,"new":!0,del:!0,filter:!1,"export":!0,group:!1,customize:!0}},modesHash:{edit:"Edit",mini:"Mini",json:"JSON",cards:"Cards",list:"List",charts:"Charts"},views:[],viewsHash:{},curView:null,curViewName:"",_group:!1,initialize:function(a){_.extend(this.options,a),this.render(),this.$(".dropdown-toggle").dropdown()},render:function(){var a=this.$el;a.html(this._toolbarHTML()),this.setView(this.options.defaultView||"list"),this._viewsIcon=this.$(".glyphicon-eye-open")},_toolbarHTML:function(){function a(a,b){return['<li class="dropdown" data-id="',a,'">','<a href="#" class="dropdown-toggle" data-toggle="dropdown">',Evol.UI.icon(b),' <b class="caret"></b></a>','<ul class="dropdown-menu evo-dropdown-icons">'].join("")}function b(a,b,c,e,f){d.push('<li data-id="',a,'"'),e&&d.push(' data-cardi="'+e,'"'),"label"!==f&&d.push(' data-toggle="tooltip" data-placement="bottom" title="" data-original-title="',b,'"'),d.push('><a href="#" data-id="',a,'">',Evol.UI.icon(c)),"tooltip"!==f&&d.push("&nbsp;",b),d.push("</a></li>")}function c(a,c,d,f){e.buttons&&e.buttons[a]&&b(a,c,d,f,"tooltip")}var d=[],e=this.options,f="</ul></li>";return d.push('<div class="evo-toolbar"><ul class="nav nav-pills pull-left" data-id="main">'),c("list",Evol.i18n.All,"th-list"),c("new",Evol.i18n.New,"plus"),c("del",Evol.i18n.Delete,"trash","1"),c("filter","Filter","filter","n"),c("export","Export","cloud-download","n"),e.toolbar&&(b("prev","","chevron-left","1"),b("next","","chevron-right","1"),d.push('</ul><ul class="nav nav-pills pull-right" data-id="views">'),d.push(a("views","eye-open")),c("list","List","th-list","n"),c("cards","Cards","th-large","n"),c("charts","Charts","stats","n"),c("edit","All Fields","th","1"),c("mini","Important Fields only","th-large","1"),c("json","JSON","barcode","1"),d.push(f)),d.push("</ul>",Evol.UI.html.clearer,"</div>"),d.join("")},updateModel:function(){this.refresh()},refresh:function(){return this.viewsHash.list&&this.viewsHash.list.render(),this.viewsHash.cards&&this.viewsHash.cards.render(),this},setView:function(a){var b,c=this.options,d=this.$el,e="evolw-"+a,f=this.$('[data-vid="'+e+'"]'),g=this.curView,h=this.model?this.model.collection:new c.collectionClass;if("new"===a)a=this._prevOne?this._prevOne:"edit",this.setView(a),this._isNew=!0,this.model=new c.modelClass,this.model.collection=h,this.newItem(),this.curView.options.mode="new";else if(this._isNew=!1,f.length)this.model=this.curView.model,this.curView=this.viewsHash[a],this.isNew||(this.curView.setModel?(!this.curView.collection&&m.collection&&(this.curView.collection=this.model.collection),this.curView.setModel(this.model)):this.curView.model=this.model,this.model||(this.curView.collection=h)),this.$('[data-id="views"] > li').removeClass("evo-sel").filter('[data-id="'+a+'"]').addClass("evo-sel"),f.show().siblings().not(".evo-toolbar,.evo-filters,.clearfix").hide();else{switch(f=$('<div data-vid="evolw-'+a+'"></div>'),d.children().not(".evo-toolbar,.evo-filters,.clearfix").hide(),d.append(f),b={el:f,mode:a,model:this.model,collection:this.collection,uiModel:c.uiModel,style:c.style,titleSelector:c.titleSelector},this.$('[data-id="new"]').show(),this.$('[data-id="views"] > li').removeClass("evo-sel").filter('[data-id="'+a+'"]').addClass("evo-sel"),a){case"edit":case"mini":case"json":g=new Evol.ViewOne[this.modesHash[a]](b).render(),this._prevOne=a;break;case"charts":case"cards":case"list":g=new Evol.ViewMany[this.modesHash[a]](b).render(),this._prevMany=a;break;case"export":g=new Evol.ViewExport(b),f.addClass("panel panel-info").slideDown()}this.curView=g,this.curViewName=a,this.viewsHash[a]=g,this.curView._updateTitle?this.curView._updateTitle():$(this.options.titleSelector).html(this.curView.getTitle())}return this.setMode(a),this},getToolbarButtons:function(){if(!this._toolbarButtons){var a=this.$("li");this._toolbarButtons={ones:a.filter('li[data-cardi="1"]'),manys:a.filter('li[data-cardi="n"]'),prevNext:this.$('[data-id="prev"],[data-id="next"]'),customize:this.$('a[data-id="customize"]').parent(),views:this.$('[data-id="views"]')}}return this._toolbarButtons},setMode:function(a){function b(a,b){Evol.UI.setVisible(c.ones,a),Evol.UI.setVisible(c.manys,b)}if(this.$el){var c=this.getToolbarButtons();if(Evol.UI.setVisible(c.customize,"json"!=a),c.prevNext.hide(),Evol.UI.setVisible(c.views,"export"!==a),this._viewsIcon){var d="glyphicon-eye-open",e="glyphicon-eye-close";"mini"===a||"json"===a?this._viewsIcon.removeClass(d).addClass(e):this._viewsIcon.removeClass(e).addClass(d)}this._isNew||"export"===a?(b(!1,!1),this._isNew):"cards"===a||"list"===a||"charts"===a?(this._prevMany=a,b(!1,!0)):(this._prevOne=a,b(!0,!1),c.prevNext.show()),Evol.UI.setVisible(c.manys.filter('[data-id="group"]'),"cards"===a)}},showFilter:function(){if(!this._filters){var a=this,b=$(Evol.UI.HTMLEmptyPanel("filters","evo-filters","info"));this.$(".evo-toolbar").after(b),this._filters=new Evol.ViewFilter({el:b,fields:Evol.Dico.getFields(this.options.uiModel)}).render(),b.on("change.filter",function(){a.curView.setFilter(a._filters.val()).render()})}return this},showGroup:function(){return this._group=!0,this.curView.showGroup(),this},setData:function(a){return this.curView&&this.curView.setData(a),this},getData:function(){return this.curView?this.curView.getData():null},browse:function(a){var b=this.curView.model;if(this.model&&this.model.collection&&this.model.collection.length){var c=this.model.collection,d=c.length-1,e=_.indexOf(c.models,b);e="prev"===a?e>0?e-1:d:d>e?e+1:0,b=c.models[e]}else b=null;return this.model=b,this.curView.setModel(b),this},saveItem:function(a){function b(b){a?c.newItem():(c.model=b,c._isNew=!1,c.setMode("edit"),d.setModel(b)),d._updateTitle()}var c=this,d=this.curView,e=d.validate();if(""===e){var f=Evol.UI.capFirstLetter(this.options.uiModel.entity);if(this._isNew){var g=this.model&&this.model.collection?this.model.collection:this.collection;g?(g.create(this.getData(),{success:function(a){b(a),c.setMessage("Record saved.",Evol.i18n.getLabel("status.added",f,d.getTitle()),"success")},error:function(){alert("error")}}),this.options.mode="edit"):alert("Can't save record b/c no collection is specified.")}else this.model.set(this.getData()),this.model.save("","",{success:function(a){b(a),c.setMessage("Record saved.",Evol.i18n.getLabel("status.updated",f,d.getTitle()),"success")},error:function(){alert("error")}})}else this.setMessage("Invalid data.",e,"warning");return this},cancelItem:function(){},newItem:function(){var a=this.curView;return a.clear()._updateTitle(Evol.i18n.getLabel("NewEntity",this.options.uiModel.entity,a.getTitle()))},deleteItem:function(){var a=this.options.uiModel.entity,b=this.curView.getTitle(),c=this.curView.model;if(c&&confirm(Evol.i18n.getLabel("DeleteEntity",a,b))){var d=this,e=this.collection,f=_.indexOf(e.models,c),g=f,h=null;e.length>1&&(g=0===f?1:f<e.length-1?f+1:f-1,h=e.at(g)),h&&(h.collection=e),c.destroy({success:function(){0===e.length?d.curView.clear():(this.model=h,d.curView.setModel(h)),d.setMessage("Record Deleted.",Evol.i18n.getLabel("status.deleted",Evol.UI.capFirstLetter(a),b),"success")},error:function(){alert("error")}})}},setMessage:function(a,b,c){var d=this.$('[data-id="msg"]');return d.length?d.html("<strong>"+a+"</strong>"+b).show():this.$el.prepend(Evol.UI.HTMLMsg(a," "+b,c)),this},clearMessage:function(){return this.$('[data-id="msg"]').remove(),this},action_view:function(a,b){"cancel"===b||this.saveItem("save-add"===b)},click_toolbar:function(a){var b=$(a.target);"A"!==b.tagName&&(b=b.closest("a"));var c=b.data("id");switch(a.preventDefault(),a.stopImmediatePropagation(),c){case"del":this.deleteItem();break;case"customize":this.curView.customize();break;case"group":this.showGroup();break;case"filter":this.showFilter();break;case"prev":case"next":this.browse(c);break;case"new-field":Evol.Dico.showDesigner("","field",b);break;default:c&&""!==c&&this.setView(c)}this.$el.trigger("toolbar."+c)},click_navigate:function(a,b){var c=this.collection.get(b.id);a.stopImmediatePropagation(),this.model=c,this.setView(this._prevOne||"edit"),this.curView.setModel(c)},click_download:function(){alert("Sorry, no demo server yet...")}});var Evol=Evol||{},evoLangXpt=Evol.i18n.export;Evol.ViewExport=Backbone.View.extend({version:"0.0.2",events:{"change .evol-xpt-format":"click_format","change input":"click_preview","click .evol-xpt-more":"click_toggle_sel","click #XP":"click_submit"},options:{toolbar:!0,model:null,uiModel:null,many:!0,style:"normal",prefix:"tbr"},viewName:"export",initialize:function(a){_.extend(this.options,a),this.render();var b=this.$el;return b.addClass("Panel"),this._preview("CSV"),this},render:function(){return this.$el.html(this._renderHTML()),this._preview("CSV"),this},_renderHTML:function(){var a=[],b=Evol.UI,c=this.options,d=c.prefix||"",e=this.getFields();a.push('<div class="evol-xpt-form"><div class="evol-xpt-flds"><fieldset>'),a.push('<div class="evol-id">',b.fieldLabel("",evoLangXpt.ExportFields),"</div>");for(var f=0,g=e.length;g>f;f++){var h=e[f],i=h.label,j="fx-"+h.id;(null===i||""===i)&&(i="("+j+")"),a.push('<div><input type="checkbox" value="1" id="',j,'" checked="true"><label class="checkbox" for="',j,'">',i,"</label></div>"),10==f&&g>14&&a.push(EvoExport.html_more2(evoLangXpt.AllFields))}g>14&&a.push("</div>"),a.push('</fieldset></div><div class="evol-xpt-para">');var k=d+"evol-xpt-format",l=evoLangXpt.ExportFormats.split("-");return a.push('<label for="',k,'">',evoLangXpt.ExportFormat,"</label>",b.input.select(k,"evol-xpt-format",!1,[{id:"CSV",text:l[0]},{id:"TAB",text:l[3]},{id:"HTML",text:l[1]},{id:"JSON",text:l[5]},{id:"SQL",text:l[2]},{id:"XML",text:l[4]}])),a.push('<div class="evol-xpt-opts">'),k=d+"FLH",a.push('<div class="evol-FLH clearfix">'),a.push(b.input.checkbox(k,!0),b.fieldLabelSpan(k,evoLangXpt.ExportFirstLine)),a.push('</div><div id="',d,'CSV">'),a.push('<div data-id="csv2" class="evol-w120">',b.fieldLabel("FLS_evol",evoLangXpt.ExportSeparator),b.input.text(d+"FLS_evol",",",0),"</div>"),a.push("</div>"),_.each(["XML","HTML","SQL","JSON"],function(b){a.push('<div id="',d,b,'" style="display:none;"></div>')}),a.push("</div>"),a.push('<label>Export Preview</label><div class="evol-xpt-preview"></div>'),a.push("</div>"),a.push('<div class="evol-buttons form-actions">'),a.push('<input class="btn btn-primary" id="XP" type="submit" value="',evoLangXpt.DownloadEntity.replace("{0}",this.options.uiModel.entities),'"/>'),a.push("</div></div>"),a.join("")},setModel:function(a){this.options.model=a},showFormatOpts:function(a){var b="#"+(this.options.prefix||"");switch(this.$el,a){case"TAB":a="CSV",this.$('[data-id="csv2"]').hide();break;case"CSV":this.$('[data-id="csv2"]').show();break;case"HTML":case"XML":case"SQL":case"JSON":var c=this.$(b+a);""===c.html()&&c.html(EvoExport["form"+a](this.options.uiModel.entity))}var d=this.$(b+a).show().siblings().hide(),e=d.filter(".evol-FLH");"TAB"===a||"CSV"===a?e.show():e.hide(),EvoExport.cFormat=a},getFields:function(){var a=this.options;return this.fields||(this.fields=Evol.Dico.getFields(a.uiModel,a.fnFilter,a.mode)),this.fields},getTitle:function(){return this.options.many?Evol.i18n.getLabel("export.ExportEntities",this.options.uiModel.entities):Evol.i18n.getLabel("export.ExportEntity",this.options.uiModel.entity)},_preview:function(a){var b=[];if(this.model&&this.model.collection){var c=this.model.collection.models,d=this.getFields(),e=this.$(".evol-xpt-flds > fieldset input:checked"),f={},g="#"+this.options.prefix,h=this.$(g+"FLH").prop("checked");switch(b.push('<textarea class="Field evol-xpt-val form-control">'),_.each(e,function(a){f[a.id.substring(3)]=""}),d=_.filter(d,function(a){return a.id&&_.has(f,a.id)?!0:void 0}),a){case"CSV":case"TAB":case"TXT":var i=d.length-1,j=Evol.UI.trim(this.$(g+"FLS_evol").val());"TAB"==a&&(j="&#09;"),h&&(_.each(d,function(a,c){b.push(a.label),i>c&&b.push(j)}),b.push("\n")),_.each(c,function(a){_.each(d,function(c,d){var e=a.get(c.id);e&&b.push(e),i>d&&b.push(j)}),b.push("\n")}),b.push("\n");break;case"HTML":b.push("<table>\n"),h&&(b.push("<tr>\n"),_.each(d,function(a){b.push("<th>",a.id,"</th>")}),b.push("</tr>\n")),_.each(c,function(a){b.push("<tr>"),_.each(d,function(c){var d=a.get(c.id);d?b.push("<td>",d,"</td>"):b.push("<td></td>")}),b.push("</tr>\n")}),b.push("</table>");break;case"JSON":b.push(JSON.stringify(this.model.toJSON(),null,2));break;case"SQL":var k=d.length-1,l=this.$("#evoxpTRS1").prop("checked"),m=this.$("#evoxpTRS2").prop("checked"),n=this.$("#evoTable").val().replace(/ /g,"_"),o=["INSERT INTO ",n," ("];""===n&&(n=this.options.uiModel.entity.replace(/ /g,"_")),_.each(d,function(a,b){o.push(a.id),k>b&&o.push(", ")}),o.push(")\n VALUES ("),o=o.join(""),l&&b.push("BEGIN TRANSACTION\n"),m&&b.push("SET IDENTITY_INSERT ",n," ON;\n");for(var p=0,q=c.length;q>p;p++){b.push(o);for(var r=c[p],s=0,t=d.length;t>s;s++){var u=r.get(d[s].id);b.push('"',u,'"'),k>s&&b.push(", ")}b.push(");\n")}m&&b.push("SET IDENTITY_INSERT ",n," OFF;\n"),l&&b.push("COMMIT TRANSACTION\n");break;case"XML":var v=this.$("#evoRoot").val()||this.options.uiModel.entity.replace(/ /g,"_");b.push("<xml>\n"),_.each(c,function(a){b.push("<",v," "),_.each(d,function(c){b.push(c.id,'="',a.get(c.id),'" ')}),b.push("></",v,">\n")}),b.push("</xml>")}b.push("</textarea>")}else b.push(Evol.UI.HTMLMsg(Evol.i18n.nodata,"","info"));this.$(".evol-xpt-preview").html(b.join(""))},val:function(a){return"undefined"==typeof a?this._getValue():(this._setValue(a),this)},_ValFields:function(){for(var a=[],b=this.$(".evol-xpt-flds input:checked").not("#showID"),c=0,d=b.length;d>c;c++){var e=$(b[c]);a.push(e.attr("id"))}return a},_getValue:function(){var a={format:this._bFormat.val(),fields:this._ValFields(),options:{}},b=this.$(".evol-xpt-para input"),c=b.eq(0),d="undefined"!==c.attr("checked");return a.options[c.attr("id")]=d,a},click_format:function(a){var b=$(a.target).val();"XML"===b&&(this.$("#XML").html(EvoExport.formXML(this.options.uiModel.entity)).show().siblings().not(".evol-FLH").hide(),EvoExport.cFormat="XML"),this.showFormatOpts(b),this._preview(b),this.$el.trigger("change.export","format",b)},click_preview:function(){var a=this.$(".evol-xpt-format").val();this._preview(a)},click_toggle_sel:function(a){$(a.currentTarget).hide().next().slideDown()},click_submit:function(){this.$el.trigger("submit.export")}});var EvoExport={cFormat:"CSV",html_more2:function(a){return['<a href="javascript:void(0)" class="evol-xpt-more">',a,'</a><div style="display:none;">'].join("")},formHTML:function(){return""},formXML:function(a){return[EvoExport.html_more2("options"),EvoExport.formEntityName("evoRoot",evoLangXpt.xpXMLroot,a),Evol.UI.fieldLabel("evoxpC2X",evoLangXpt.xpColMap),"</div>"].join("")},formJSON:function(){return""},formSQL:function(a){return[EvoExport.html_more2("options"),EvoExport.formEntityName("evoTable",evoLangXpt.xpSQLTable,a),"<div>",Evol.UI.input.checkbox("evoxpTRS2","0"),Evol.UI.fieldLabelSpan("evoxpTRS2",evoLangXpt.xpSQLId),"</div>","<div>",Evol.UI.input.checkbox("evoxpTRS1","0"),Evol.UI.fieldLabelSpan("evoxpTRS1",evoLangXpt.xpSQLTrans),"</div>","</div>"].join("")},formEntityName:function(a,b,c){return[Evol.UI.fieldLabel(a,b),Evol.UI.input.text(a,c.replace(" ","_"),30),"<br/>"].join("")}};

@@ -23,3 +23,7 @@ module.exports = function (grunt) {

src: [
// jQuery & jQuery UI
'bower_components/jquery/jquery.js',
//'bower_components/jquery-ui/ui/jquery.ui.widget.js',
// Backbone & Underscore
'bower_components/underscore/underscore.js',

@@ -29,2 +33,4 @@ //'bower_components/underscore.string/lib/underscore.string.js',

'bower_components/backbone.localStorage/backbone.localStorage.js',
// Twitter Bootstrap
'bower_components/bootstrap/js/modal.js',

@@ -34,2 +40,3 @@ 'bower_components/bootstrap/js/tooltip.js',

'bower_components/bootstrap/js/dropdown.js'
],

@@ -44,2 +51,4 @@ dest: '<%= pkg.target %>/vendors.js'

'js/dico.js',
'js/many.js',

@@ -51,23 +60,7 @@ 'js/many-*.js',

'js/toolbar.js',
'js/export.js',
'js/filter.js',
'js/ui-models/dico/field.js'
//'js/filter.js',
'js/export.js'
//'js/ui-models/dico/field.js'
],
dest: '<%= pkg.target %>/evolutility.js'
},
css: {
options: {
banner: '<%= banner %>',
separator: '\n'
},
src: [
//'app/css/demo.css',
'css/one.css',
'css/many.css',
'css/ui-dico.css',
'css/toolbar.css',
'js/export.css',
'js/filter.css'
],
dest: '<%= pkg.target %>/evolutility.css'
}

@@ -124,2 +117,28 @@ },

}
},
// *************************************************************************************
// LESS
// *************************************************************************************
less: {
options: {
},
dev: {
files: {
"dist/css/evolutility.css": "less/evol.less"
}
},
demo: {
files: {
"dist/css/demo.css": "less/demo.less"
}
},
prod: {
options: {
yuicompress: true
},
files: {
"dist/css/evolutility.min.css": "less/evol.less"
}
}
}

@@ -137,2 +156,3 @@

grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-less');

@@ -146,9 +166,9 @@

// Dev only task(s).
grunt.registerTask('dev', ['concat:js', 'concat:css']);
// Dev task(s).
grunt.registerTask('dev', ['concat:js', 'less:dev', 'less:demo']);
// Prod only task(s).
grunt.registerTask('prod', ['jshint', 'dev', 'concat:vendors', 'uglify']);
// Prod task(s).
grunt.registerTask('prod', ['jshint', 'dev', 'concat:vendors', 'less:prod', 'uglify']);
};
/*! ***************************************************************************
*
* evol-utility : demo.js
* evolutility :: demo.js
*
* Demo
*
* https://github.com/evoluteur/evolutility
* Copyright (c) 2014, Olivier Giulieri

@@ -20,3 +21,3 @@ *

if($ui.html()==''){
$ui.html(EvoUI.inputTextMJSON('uimodel2', uiModel, null, 12));
$ui.html(Evol.UI.input.textMJSON('uimodel2', uiModel, null, 12));
}

@@ -28,10 +29,10 @@ $ui.slideDown();

function setDemo(uiModel, localStorage, data){
M = Backbone.Model.extend({
localStorage: new Backbone.LocalStorage(localStorage)
});
Ms = Backbone.Collection.extend({
model: M,
localStorage: new Backbone.LocalStorage(localStorage)
});
function setDemo(uiModel, localStorage, data, style){
var M = Backbone.Model.extend({
localStorage: new Backbone.LocalStorage(localStorage)
}),
Ms = Backbone.Collection.extend({
model: M,
localStorage: new Backbone.LocalStorage(localStorage)
});

@@ -41,3 +42,5 @@ var ms = new Ms();

success: function(collection){
EvoUI.insertCollection(collection, data);
if(collection.length===0){
Evol.UI.insertCollection(collection, data);
}
var m = ms.models[0];

@@ -48,7 +51,10 @@ var el =$('#evol'),

mode: 'one',
style:'panel-primary',
style: style,// || 'panel-primary',
customize:false,
model: m,
modelClass: M,
collection: ms,
uiModel: uiModel
collectionClass: Ms,
uiModel: uiModel,
titleSelector: '#title'
});

@@ -55,0 +61,0 @@

/*! ***************************************************************************
*
* evol-utility : export.js
* evolutility :: export.js
*
* https://github.com/evoluteur/evolutility
* Copyright (c) 2014, Olivier Giulieri

@@ -9,20 +10,15 @@ *

var Evol = Evol || {},
EvoUI = Evol.UI,
EvoDico = Evol.Dico,
evoLangXpt = EvolLang.export;
evoLangXpt = Evol.i18n.export;
Evol.ViewExport = Backbone.View.extend({
version: '0.0.1',
version: '0.0.2',
events: {
"change select.evol-xpt-format": "click_format",
"change .evol-xpt-format": "click_format",
'change input': 'click_preview', //[type="checkbox"],
'click .evol-more': 'click_toggle_sel',
'click .evol-xpt-more': 'click_toggle_sel',
'click #XP': 'click_submit'
//
// TODO #tbrevol-xpt-format is a bug if change prefix...
},

@@ -32,6 +28,5 @@

toolbar: true,
cardinality: 'one',
model: null,
uiModel: null,
defaultView: 'list',
many: true,
style: 'normal',

@@ -41,9 +36,6 @@ prefix: 'tbr'

many: true,
viewName: "export",
initialize: function (opts) {
this.options.fields=opts.fields;
this.options.uiModel=opts.uiModel;
this.options.prefix=opts.prefix;
_.extend(this.options, opts);
this.render();

@@ -66,2 +58,3 @@ var e = this.$el;

var h = [],
EvoUI = Evol.UI,
opts = this.options,

@@ -72,8 +65,7 @@ prefix = opts.prefix || '',

//string fieldName, fieldlabel, expOut, buffer;
h.push('<table class="evol-xpt-form"><tr><td class="evol-xpt-flds"><fieldset>');
h.push('<div class="evol-xpt-form"><div class="evol-xpt-flds"><fieldset>');
//### list of columns to export #########################################
h.push('<div class="evol-id">', EvoUI.fieldLabel('', evoLangXpt.ExportFields),
EvoUI.inputCheckbox('showID','1'), '<label for="showID">', evoLangXpt.IDkey, '</label>',
'</div>'
);
//EvoUI.input.checkbox('showID','1'), '<label for="showID">', evoLangXpt.IDkey, '</label>',
'</div>');
for (var i = 0, iMax = fields.length; i < iMax; i++) {

@@ -87,23 +79,22 @@ var f = fields[i],

h.push('<div><input type="checkbox" value="1" id="', fID, '" checked="true"><label class="checkbox" for="', fID, '">', fLabel, '</label></div>');
if (i == 12 && iMax > 16){
if (i == 10 && iMax > 14){
h.push(EvoExport.html_more2(evoLangXpt.AllFields));
}
}
if (iMax > 16){
if (iMax > 14){
h.push('</div>');
}
h.push('</fieldset></td><td class="evol-xpt-para">'); // table = 2 columns
h.push('</fieldset></div><div class="evol-xpt-para">'); // table = 2 columns
//##### export formats ########################################
var fId = prefix + 'evol-xpt-format',
myLabels = evoLangXpt.ExportFormats.split('-');
h.push('<label for="', fId, '">', evoLangXpt.ExportFormat, '</label>');
h.push(
EvoUI.inputSelectBegin(fId,'evol-xpt-format'),
EvoUI.inputOption('CSV', myLabels[0]),
EvoUI.inputOption('TAB', myLabels[3]),
EvoUI.inputOption('HTML', myLabels[1]),
EvoUI.inputOption('JSON', myLabels[5]),
EvoUI.inputOption('SQL', myLabels[2]),
EvoUI.inputOption('XML', myLabels[4]),
'</select>'
h.push('<label for="', fId, '">', evoLangXpt.ExportFormat, '</label>',
EvoUI.input.select(fId,'evol-xpt-format', false, [
{id: 'CSV', text: myLabels[0]},
{id: 'TAB', text: myLabels[3]},
{id: 'HTML', text: myLabels[1]},
{id: 'JSON', text: myLabels[5]},
{id: 'SQL', text: myLabels[2]},
{id: 'XML', text: myLabels[4]}
])
);

@@ -115,3 +106,3 @@ h.push('<div class="evol-xpt-opts">');

//h.push('<label>', evoLangXpt.ExportHeader, '</label>');
h.push(EvoUI.inputCheckbox(fId, true), EvoUI.fieldLabelSpan(fId, evoLangXpt.ExportFirstLine));
h.push(EvoUI.input.checkbox(fId, true), EvoUI.fieldLabelSpan(fId, evoLangXpt.ExportFirstLine));
//##### CSV, TAB - First line for field names #######

@@ -121,7 +112,8 @@ h.push('</div><div id="', prefix, 'CSV">');

//# - csv - any separator #######
h.push('<div id="', prefix, 'csv2" class="evol-w120">',
EvoExport.html_more2('options'),
h.push('<div data-id="csv2" class="evol-w120">',
//EvoExport.html_more2('options'),
//.evol-FLH
EvoUI.fieldLabel('FLS_evol', evoLangXpt.ExportSeparator),
EvoUI.inputText('FLS_evol', ',', 0),
'</div></div>');
EvoUI.input.text(prefix+'FLS_evol', ',', 0),
'</div>'); // </div>
h.push('</div>');

@@ -135,3 +127,3 @@ _.each(['XML','HTML','SQL','JSON'], function(f){

h.push('</td></tr></table>');
h.push('</div>');
// ## Samples

@@ -143,9 +135,13 @@ //h.push(this._samples());

evoLangXpt.DownloadEntity.replace('{0}', this.options.uiModel.entities),
'">');
h.push('</div>');
'"/>');
h.push('</div></div>');
return h.join('');
},
setModel: function(model){
this.options.model=model;
},
showFormatOpts: function (xFormat) {
var prefix = '#'+(this.prefix||''),
var prefix = '#'+(this.options.prefix||''),
e=this.$el;

@@ -155,6 +151,6 @@ switch (xFormat) {

xFormat = 'CSV';
this.$('#csv2').hide();
this.$('[data-id="csv2"]').hide();
break;
case 'CSV':
this.$('#csv2').show();
this.$('[data-id="csv2"]').show();
break;

@@ -185,3 +181,3 @@ case 'HTML':

if(!this.fields){
this.fields=EvoDico.fields(opts.uiModel,opts.fnFilter,opts.mode);
this.fields=Evol.Dico.getFields(opts.uiModel,opts.fnFilter,opts.mode);
}

@@ -191,134 +187,154 @@ return this.fields;

getTitle: function(){
if(this.options.many){
return Evol.i18n.getLabel('export.ExportEntities', this.options.uiModel.entities);
}else{
return Evol.i18n.getLabel('export.ExportEntity', this.options.uiModel.entity);
}
},
_preview: function (format) {
var data = this.model.collection.models,
flds = this.getFields(),
h = ['<textarea class="Field evol-xpt-val form-control">'],
fldsDom = this.$('.evol-xpt-flds > fieldset input:checked'),
fldsDomHash = {};
var h=[];
if(this.model && this.model.collection){
var data = this.model.collection.models,
flds = this.getFields(),
fldsDom = this.$('.evol-xpt-flds > fieldset input:checked'),
fldsDomHash = {},
prefix='#'+ this.options.prefix,
useHeader = this.$(prefix+'FLH').prop('checked');
_.each(fldsDom, function(fd){
fldsDomHash[fd.id.substring(3)]='';
});
flds=_.filter(flds, function(f){
if(f.id && _.has(fldsDomHash, f.id)){
return true;
}
});
switch (format) {
case 'CSV':
case 'TAB':
case 'TXT':
var iMax=flds.length-1,
sep = this.$('#FLS_evol').val().trim(),
useHeader = this.$('#FLH').prop('checked');
if(format=='TAB'){
sep='&#09;';
h.push('<textarea class="Field evol-xpt-val form-control">');
_.each(fldsDom, function(fd){
fldsDomHash[fd.id.substring(3)]='';
});
flds=_.filter(flds, function(f){
if(f.id && _.has(fldsDomHash, f.id)){
return true;
}
//header
if (useHeader) {
_.each(flds, function(f,idx){
h.push(f.label);
if(idx<iMax){
h.push(sep);
}
});
switch (format) {
case 'CSV':
case 'TAB':
case 'TXT':
var iMax=flds.length-1,
sep = Evol.UI.trim(this.$(prefix+'FLS_evol').val());
if(format=='TAB'){
sep='&#09;';
}
//header
if (useHeader) {
_.each(flds, function(f,idx){
h.push(f.label);
if(idx<iMax){
h.push(sep);
}
});
h.push('\n');
}
//data
_.each(data, function(m){
_.each(flds, function(f,idx){
var mj = m.get(f.id);
if (mj) {
h.push(mj);
}
if(idx<iMax){
h.push(sep);
}
});
h.push('\n');
});
h.push('\n');
}
//data
_.each(data, function(m){
break;
case 'HTML':
//header
h.push('<table>\n');
if (useHeader) {
h.push('<tr>\n');
_.each(flds, function(f){
h.push('<th>', f.id, '</th>');
});
h.push('</tr>\n');
}
//data
_.each(data, function(d,idx){
h.push('<tr>');
_.each(flds, function(f){
var mj = d.get(f.id);
if (mj) {
h.push('<td>', mj, '</td>');
} else {
h.push('<td></td>');
}
});
h.push('</tr>\n');
});
h.push('</table>');
break;
case 'JSON':
h.push(JSON.stringify(this.model.toJSON(), null, 2));
break;
case 'SQL':
var fMax = flds.length -1,
optTransaction = this.$('#evoxpTRS1').prop('checked'),
optIdInsert = this.$('#evoxpTRS2').prop('checked'),
sqlTable = this.$('#evoTable').val().replace(/ /g,'_'),
sql = ['INSERT INTO ',sqlTable,' ('];
if(sqlTable===''){
sqlTable = this.options.uiModel.entity.replace(/ /g,'_');
}
_.each(flds, function(f,idx){
var mj = m.get(f.id);
if (mj) {
h.push(mj);
sql.push(f.id);
if(idx<fMax){
sql.push(', ');
}
if(idx<iMax){
h.push(sep);
}
});
h.push('\n');
});
h.push('\n');
break;
case 'HTML':
//header
h.push('<table>\n<tr>');
_.each(flds, function(f){
h.push('<th>', f.id, '</th>');
});
h.push('</tr>\n');
//data
_.each(data, function(d,idx){
h.push('<tr>');
_.each(flds, function(f){
var mj = d.get(f.id);
if (mj) {
h.push('<td>', mj, '</td>');
} else {
h.push('<td></td>');
}
});
h.push('</tr>\n');
});
h.push('</table>');
break;
case 'JSON':
h.push(JSON.stringify(this.model.toJSON(), null, 2));
break;
case 'SQL':
var fMax = flds.length -1,
optTransaction = this.$('#evoxpTRS1').prop('checked'),
optIdInsert = this.$('#evoxpTRS2').prop('checked'),
sqlTable = this.$('#evoTable').val().replace(/ /g,'_'), //this.options.uiModel.entity.replace(/ /g,'_'),
sql = ['INSERT INTO ',sqlTable,' ('];
_.each(flds, function(f,idx){
sql.push(f.id);
if(idx<fMax){
sql.push(', ');
sql.push(')\n VALUES (');
sql = sql.join('');
//options
if(optTransaction){
h.push('BEGIN TRANSACTION\n');
}
});
sql.push(')\n VALUES (');
sql = sql.join('');
//options
if(optTransaction){
h.push('BEGIN TRANSACTION\n');
}
if(optIdInsert){
h.push('SET IDENTITY_INSERT ',sqlTable,' ON;\n');
}
//data
for (var i = 0, iMax1 = data.length; i < iMax1; i++) {
h.push(sql);
var m = data[i];
for (var j = 0, jMax = flds.length; j < jMax; j++) {
var mj = m.get(flds[j].id);
h.push('"', mj, '"');
if(j<fMax){
h.push(', ');
if(optIdInsert){
h.push('SET IDENTITY_INSERT ',sqlTable,' ON;\n');
}
//data
for (var i = 0, iMax1 = data.length; i < iMax1; i++) {
h.push(sql);
var m = data[i];
for (var j = 0, jMax = flds.length; j < jMax; j++) {
var mj = m.get(flds[j].id);
h.push('"', mj, '"');
if(j<fMax){
h.push(', ');
}
}
h.push(');\n');
}
h.push(');\n');
}
//options
if(optIdInsert){
h.push('SET IDENTITY_INSERT ',sqlTable,' OFF;\n');
}
if(optTransaction){
h.push('COMMIT TRANSACTION\n');
}
break;
case 'XML':
var elemName = this.$('#evoRoot').val();
h.push('<xml>\n');
_.each(data, function(m){
h.push('<', elemName, ' ');
_.each(flds, function(f){
h.push(f.id, '="', m.get(f.id), '" ');
//options
if(optIdInsert){
h.push('SET IDENTITY_INSERT ',sqlTable,' OFF;\n');
}
if(optTransaction){
h.push('COMMIT TRANSACTION\n');
}
break;
case 'XML':
var elemName = this.$('#evoRoot').val() || this.options.uiModel.entity.replace(/ /g,'_');
h.push('<xml>\n');
_.each(data, function(m){
h.push('<', elemName, ' ');
_.each(flds, function(f){
h.push(f.id, '="', m.get(f.id), '" ');
});
h.push('></', elemName, '>\n');
});
h.push('></', elemName, '>\n');
});
h.push('</xml>');
break;
h.push('</xml>');
break;
}
h.push('</textarea>');
}else{
h.push(Evol.UI.HTMLMsg(Evol.i18n.nodata,'','info'));
}
h.push('</textarea>');
this.$('.evol-xpt-preview')

@@ -360,3 +376,3 @@ .html(h.join(''));

click_format: function (evt) {
var format = this.$('.evol-xpt-format').val();
var format = $(evt.target).val();//this.$('.evol-xpt-format').val();
if (format === 'XML') {

@@ -367,5 +383,4 @@ this.$('#XML').html(EvoExport.formXML(this.options.uiModel.entity))

EvoExport.cFormat = 'XML';
} else {
this.showFormatOpts(format);
}
this.showFormatOpts(format);
this._preview(format);

@@ -398,3 +413,3 @@ this.$el.trigger('change.export', 'format', format);//evt.currentTarget.val()

return [
'<a href="javascript:void(0)" class="evol-more">', label, '</a><div class="evol-more-content">'
'<a href="javascript:void(0)" class="evol-xpt-more">', label, '</a><div style="display:none;">'
].join('');

@@ -408,7 +423,6 @@ },

formXML: function (entity) {
var b2 = 'evoxpC2X';
return [
EvoExport.html_more2('options'),
EvoExport.formEntityName('evoRoot', evoLangXpt.xpXMLroot, entity),
EvoUI.fieldLabel(b2, evoLangXpt.xpColMap),
Evol.UI.fieldLabel('evoxpC2X', evoLangXpt.xpColMap),
'</div>'

@@ -426,4 +440,4 @@ ].join('');

EvoExport.formEntityName('evoTable', evoLangXpt.xpSQLTable, entity),
'<div>', EvoUI.inputCheckbox('evoxpTRS2', '0'), EvoUI.fieldLabelSpan('evoxpTRS2', evoLangXpt.xpSQLId), '</div>',
'<div>', EvoUI.inputCheckbox('evoxpTRS1', '0'), EvoUI.fieldLabelSpan('evoxpTRS1', evoLangXpt.xpSQLTrans), '</div>',
'<div>', Evol.UI.input.checkbox('evoxpTRS2', '0'), Evol.UI.fieldLabelSpan('evoxpTRS2', evoLangXpt.xpSQLId), '</div>',
'<div>', Evol.UI.input.checkbox('evoxpTRS1', '0'), Evol.UI.fieldLabelSpan('evoxpTRS1', evoLangXpt.xpSQLTrans), '</div>',
'</div>'

@@ -435,4 +449,4 @@ ].join('');

return [
EvoUI.fieldLabel(id, label),
EvoUI.inputText(id, entity.replace(' ', '_'), 30),'<br/>'
Evol.UI.fieldLabel(id, label),
Evol.UI.input.text(id, entity.replace(' ', '_'), 30),'<br/>'
].join('');

@@ -439,0 +453,0 @@ }

/*! ***************************************************************************
*
* evol-utility : filter.js
* evolutility :: filter.js
*
* Depends:
* backbone/button.js
*
* https://github.com/evoluteur/evolutility
* Copyright (c) 2014, Olivier Giulieri

@@ -13,5 +11,3 @@ *

var Evol = Evol || {},
EvoUI = Evol.UI,
EvoDico = Evol.Dico,
evoLang=EvolLang.filters;
evoLang=Evol.i18n.filters;

@@ -35,4 +31,8 @@ var evoAPI={

events: {
'click .evo-filters > button > .glyphicon-remove': 'click_remove'
//'list.navigate div': 'click_navigate'
'click .evo-filters > button': 'click_editFilter',
'click .evo-filters-btns > button > .glyphicon-remove': 'click_remove',
'click .evo-bDel': '_removeEditor',
'click .evo-bNew': 'click_new',
'click .evo-bAdd': 'click_add'
// TODO move other events here
},

@@ -50,4 +50,3 @@

initialize: function (opts) {
this.options.fields=opts.fields;
//this.options.uiModel=opts.uiModel;
_.extend(this.options, opts);
return this;

@@ -57,7 +56,7 @@ },

render: function(){
var bClass='btn btn-sm',
var bClass='btn',
bLabels=this.options.buttonLabels,
that=this,
e=this.$el,
h=['<div class="evo-filters"></div>',
h=['<div class="evo-filters-btns">',
'<button class="evo-bNew btn-primary ',bClass,'">',evoLang.bNewFilter,'</button>'];

@@ -67,5 +66,6 @@ if(this.options.submitButton){

}
h.push('<div class="evo-editFilter"></div>',
'<button class="evo-bAdd btn-primary ',bClass,'" style="display:none;">',EvoUI.icon('ok'),'</button>',//, '&nbsp;', evoLang.bAddFilter
'<button class="evo-bDel ',bClass,'" style="display:none;">',EvoUI.icon('remove'),'</button>');//, '&nbsp;', evoLang.bCancel
h.push('</div><div class="evo-editFilter">',
'<button class="evo-bAdd ',bClass,' btn-primary" style="display:none;">',Evol.UI.icon('ok'),'</button>', //, '&nbsp;', evoLang.bAddFilter
'<button class="evo-bDel ',bClass,'" style="display:none;">',Evol.UI.icon('remove'),'</button>', //, '&nbsp;', evoLang.bCancel
'</div>');
this._step=0;

@@ -80,3 +80,3 @@ e.html(h.join(''));

text: bLabels
}).on('click', function(e){
}).on('click', function(){
that.$el.trigger('submit.filter');

@@ -86,23 +86,7 @@ });

// - editor button new
this._bNew=e.find('.evo-bNew').button().on('click', function(e){
if(that._step<1){
that._setEditorField();
that._step=1;
}
that._bAdd.find('.ui-button-text').html(evoLang.bAddFilter);
});
this._bNew=e.find('.evo-bNew').button();
// - editor button add
this._bAdd=e.find('.evo-bAdd').button().on('click', function(evt){
var data=that._getEditorData();
if(that._cFilter){
that._enableFilter(data, that.options.highlight);
}else{
that.addFilter(data);
}
that._removeEditor();
});
this._bAdd=e.find('.evo-bAdd').button();
// - editor button cancel
this._bDel=e.find('.evo-bDel').button().on('click', function(evt){
that._removeEditor();
});
this._bDel=e.find('.evo-bDel').button();
this._editor=e.find('.evo-editFilter')

@@ -124,3 +108,3 @@ .on('change', '#field', function(evt){

that._setEditorOperator();
if(fType==EvoDico.fieldTypes.lov || fType==EvoDico.fieldTypes.bool){
if(fType==Evol.Dico.fieldTypes.lov || fType==Evol.Dico.fieldTypes.bool){
that._setEditorValue();

@@ -144,4 +128,4 @@ }

value=$(this).val(),
valid=(value!=='') || type==EvoDico.fieldTypes.lov || type==EvoDico.fieldTypes.bool;
if(type==EvoDico.fieldTypes.number){
valid=(value!=='') || type==Evol.Dico.fieldTypes.lov || type==Evol.Dico.fieldTypes.bool;
if(type==Evol.Dico.fieldTypes.number){
valid=valid && !isNaN(value);

@@ -169,5 +153,5 @@ }else if(that._operator==evoAPI.sBetween){

});
this._filters=e.find('.evo-filters').on('click', 'a', function(){
this._filters=e.find('.evo-filters-btns').on('click', 'button', function(){
that._editFilter($(this));
}).on('click', 'a .ui-button-icon-secondary', function(evt){
}).on('click', 'btn-secondary', function(evt){
evt.stopPropagation();

@@ -240,3 +224,3 @@ var filter=$(this).parent();

}
h.push(EvoUI.icon('remove'));
h.push(Evol.UI.icon('remove'));
return h.join('');

@@ -253,3 +237,3 @@ },

this._cFilter.data('filter', filter)
.find(':first-child').html(this._htmlFilter(filter));
.html(this._htmlFilter(filter));
this._cFilter=null;

@@ -291,5 +275,5 @@ this._triggerChange();

var fields=this.options.fields,
h=[EvoUI.inputSelectBegin('field',null,true)];
h=[Evol.UI.input.selectBegin('field',null,true)];
_.each(fields, function(f){
h.push(EvoUI.inputOption(f.id, f.label));
h.push(Evol.UI.input.option(f.id, f.label));
});

@@ -310,3 +294,4 @@ h.push('</select>');

_setEditorOperator: function(cond){
var evoTypes=EvoDico.fieldTypes,
var EvoUI = Evol.UI,
evoTypes=Evol.Dico.fieldTypes,
fType=this._type;

@@ -318,3 +303,3 @@ if(this._step<2){

//h.push(evoLang.sInList);
h.push(EvoUI.inputHidden('operator',evoAPI.sInList));
h.push(EvoUI.input.hidden('operator',evoAPI.sInList));
this._operator=evoAPI.sInList;

@@ -324,18 +309,19 @@ break;

//h.push(evoLang.sEqual);
h.push(EvoUI.inputHidden('operator',evoAPI.sEqual));
h.push(EvoUI.input.hidden('operator',evoAPI.sEqual));
this._operator=evoAPI.sEqual;
break;
default:
h.push(EvoUI.inputSelectBegin('operator','',true));
h.push(EvoUI.input.selectBegin('operator','',true));
switch (fType){
case evoTypes.date:
case evoTypes.time:
case evoTypes.datetime:
if (fType==evoTypes.time){
h.push(EvoUI.inputOption(evoAPI.sEqual, evoLang.sAt),
EvoUI.inputOption(evoAPI.sNotEqual, evoLang.sNotAt));
h.push(EvoUI.input.option(evoAPI.sEqual, evoLang.sAt),
EvoUI.input.option(evoAPI.sNotEqual, evoLang.sNotAt));
}else{
h.push(EvoUI.inputOption(evoAPI.sEqual, evoLang.sOn),
EvoUI.inputOption(evoAPI.sNotEqual, evoLang.sNotOn));
h.push(EvoUI.input.option(evoAPI.sEqual, evoLang.sOn),
EvoUI.input.option(evoAPI.sNotEqual, evoLang.sNotOn));
}
h.push(EvoUI.inputOptions([
h.push(EvoUI.input.options([
{id: evoAPI.sGreater, text: evoLang.sAfter},

@@ -346,4 +332,6 @@ {id: evoAPI.sSmaller, text: evoLang.sBefore},

break;
case evoTypes.number:
h.push(EvoUI.inputOptions([
case evoTypes.integer:
case evoTypes.decimal:
case evoTypes.money:
h.push(EvoUI.input.options([
{id: evoAPI.sEqual, text: evoLang.sNumEqual},

@@ -356,3 +344,3 @@ {id: evoAPI.sNotEqual, text: evoLang.sNumNotEqual},

default:
h.push(EvoUI.inputOptions([
h.push(EvoUI.input.options([
{id: evoAPI.sEqual, text: evoLang.sEqual},

@@ -365,4 +353,4 @@ {id: evoAPI.sNotEqual, text: evoLang.sNotEqual},

}
h.push(EvoUI.inputOption(evoAPI.sIsNull, evoLang.sIsNull),
EvoUI.inputOption(evoAPI.sIsNotNull, evoLang.sIsNotNull));
h.push(EvoUI.input.option(evoAPI.sIsNull, evoLang.sIsNull),
EvoUI.input.option(evoAPI.sIsNotNull, evoLang.sIsNotNull));
h.push('</select>');

@@ -382,3 +370,3 @@ }

fType=this._type,
evoTypes=EvoDico.fieldTypes,
evoTypes=Evol.Dico.fieldTypes,
opVal=editor.find('#operator').val(),

@@ -389,3 +377,3 @@ opBetween=false,

if(fType!=evoTypes.lov && (opVal==evoAPI.sIsNull || opVal==evoAPI.sIsNotNull)){
editor.append(EvoUI.inputHidden('value',''));
editor.append(Evol.UI.input.hidden('value',''));
}else{

@@ -399,11 +387,11 @@ if(this._step<3){

if(this._field.list.length>7){
h.push(EvoUI.inputCheckbox('checkAll', true),'<label for="checkAll">',EvolLang.All,'</label>');
h.push(Evol.UI.input.checkbox('checkAll', true),'<label for="checkAll">',Evol.i18n.All,'</label>');
}
h.push(EvoUI.inputCheckboxLOV(this._field.list));
h.push('</span>');
h.push(Evol.UI.input.checkboxLOV(this._field.list),
'</span>');
break;
case evoTypes.bool:
h.push('<span id="value">',
EvoUI.inputRadio('value', '1', evoLang.yes, v!='0', 'value1'),
EvoUI.inputRadio('value', '0', evoLang.no, v=='0', 'value0'),
Evol.UI.input.radio('value', '1', evoLang.yes, v!='0', 'value1'),
Evol.UI.input.radio('value', '0', evoLang.no, v=='0', 'value0'),
'</span>');

@@ -423,3 +411,3 @@ break;

default:
h.push(EvoUI.inputText('value', '','evo-w-'));
h.push(Evol.UI.input.text('value', '','evo-w-'));
addOK=false;

@@ -470,3 +458,3 @@ }

},
evoTypes=EvoDico.fieldTypes,
evoTypes=Evol.Dico.fieldTypes,
op=filter.operator,

@@ -484,3 +472,3 @@ fv=filter.value;

fv.label=fv.value='';
}else if(vs.length==1){
}else if(vs.length===1){
op.label=evoLang.sEqual;

@@ -525,8 +513,9 @@ op.value=evoAPI.sEqual;

_hiddenValue: function(h, filter, idx){
h.push(EvoUI.inputHidden('fld-'+idx, filter.field.value),
EvoUI.inputHidden('op-'+idx, filter.operator.value),
EvoUI.inputHidden('val-'+idx, filter.value.value));
var v2=filter.value.value2;
var EvoUI = Evol.UI,
v2=filter.value.value2;
h.push(EvoUI.input.hidden('fld-'+idx, filter.field.value),
EvoUI.input.hidden('op-'+idx, filter.operator.value),
EvoUI.input.hidden('val-'+idx, filter.value.value));
if(v2){
h.push(EvoUI.inputHidden('val2-'+idx, v2));
h.push(EvoUI.input.hidden('val2-'+idx, v2));
}

@@ -538,3 +527,3 @@ },

iMax=vs.length,
h=[EvoUI.inputHidden('elem', iMax)];
h=[Evol.UI.input.hidden('elem', iMax)];
for(var i=0;i<iMax;i++){

@@ -558,3 +547,3 @@ this._hiddenValue(h, vs[i], i+1);

var v=[];
this._filters.find('a').each(function(){
this._filters.children().each(function(){
v.push($(this).data('filter'));

@@ -586,4 +575,5 @@ });

url=['filters=',iMax];
if(iMax<1)
if(iMax<1){
return '';
}
for(var i=0;i<iMax;i++){

@@ -621,2 +611,32 @@ var v=vs[i];

e.empty();
},
click_editFilter: function(evt){
evt.stopImmediatePropagation();
//var idx=$(evt.target).index();
this._setEditorValue( );
},
click_remove: function(evt){
evt.stopImmediatePropagation();
var idx=$(evt.target).parent().index();
this.removeFilter(idx);
},
click_new:function(evt){
if(this._step<1){
this._setEditorField();
this._step=1;
}
//this._bAdd.find('.ui-button-text').html(evoLang.bAddFilter);
},
click_add:function(evt){
var data=this._getEditorData();
if(this._cFilter){
this._enableFilter(data, this.options.highlight);
}else{
this.addFilter(data);
}
this._removeEditor();
}

@@ -623,0 +643,0 @@

// Evolutility Localization Library ENGLISH
// (c) 2013 Olivier Giulieri
// www.evol-utility.org
// https://github.com/evoluteur/evolutility
// (c) 2014 Olivier Giulieri
var Evol = Evol || {};
var EvolLang={
Evol.i18n = {
LOCALE:"EN", // ENGLISH
LOCALE:'EN', // ENGLISH
getLabel: function(label, string1, string2){
var l;
if(label.indexOf('.')>-1){
var ns=label.split('.');
l=this[ns[0]][ns[1]];
}else{
l=this[label];
}
if(string1){
l= l.replace('{0}',string1);
if(string2){
l= l.replace('{1}',string2);
}
}
return l;
},
// --- toolbar ---
View:"View",
Edit:"Edit",
// Login:"Login"
New:"New",
NewItem:"New Item",
NewUpload:"New Upload",
//Search:"Search",
//AdvSearch:"Advanced Search",
NewSearch:"New Search",
Selections:"Selections",
Selection:"Selection",
Export:"Export",
SearchRes:"Search Result",
//MassUpdate:"Mass Update",
Delete:"Delete",
All:"All",
//ListAll:"List All",
//Print:"Print",
DeleteEntity:"Delete this {0}?", // {0}=entity
Back2SearchResults:"Back to search results",
View:'View',
Edit:'Edit',
// Login:'Login',
New:'New',
NewEntity:'New {0}', //'New Item',
NewUpload:'New Upload',
//Search:'Search',
//AdvSearch:'Advanced Search',
//NewSearch:'New Search',
Selections:'Selections',
Selection:'Selection',
Export:'Export',
SearchRes:'Search Result',
//MassUpdate:'Mass Update',
Delete:'Delete',
All:'All',
//ListAll:'List All',
//Print:'Print',
DeleteEntity:'Delete {0} "{1}"?', // {0}=entity {1}=leadfield value
Back2SearchResults:'Back to search results',
nodata:'No data available.',
nopix:'No picture.',
nochart:'No charts available.',
badchart:'The data structure doesn\'t allow for auto-generated charts.',
// --- buttons ---
Save:'Save',
SaveAdd:'Save and Add Another',
Cancel:'Cancel',
NoChange:'No Change',
NoX:'No {0}',
// --- status ---
status:{
added:'New {0} "{1}" added.',
updated:'{0} "{1}" updated.',
deleted:'{0} "{1}" removed.'
},
// --- validation ---

@@ -44,17 +80,24 @@ validation:{

min:'"{0}" must be greater or equal to {1}.',
reg:'"{0}" must match the regular expression pattern "{1}".'
regex:'The value "{0}" is not of the expected format.'
//regex:'"{0}" must match the regular expression pattern for "{1}".'
},
// --- charts ---
charts:{
aByB:'{0} by {1}',
aB:'{0}: {1}'
},
// --- export ---
export:{
ExportEntity: "Export this {0}", // {0}=entity
ExportHeader: "Header",
ExportSeparator: "Separator",
ExportFirstLine:"First line for field names",
ExportFormat: "Export format",
ExportFields: "Fields to include in the export",
IDkey: "ID (Primary Key)",
AllFields: "Show all fields",
ExportFormats: "Comma separated (CSV, TXT, XLS...)-HTML-SQL Insert Statements (SQL)-Tab separated values (TXT)-XML-Javascript Object Notation (JSON)",
ExportEntity: 'Export {0}', // {0}=entity
ExportEntities: 'Export {0}', // {0}=entities
ExportHeader: 'Header',
ExportSeparator: 'Separator',
ExportFirstLine:'First line for field names',
ExportFormat: 'Export format',
ExportFields: 'Fields to include in the export',
IDkey: 'ID (Primary Key)',
AllFields: 'Show all fields',
ExportFormats: 'Comma separated (CSV, TXT, XLS...)-HTML-SQL Insert Statements (SQL)-Tab separated values (TXT)-XML-Javascript Object Notation (JSON)',
//xpColors:'Header color-Color odd rows-Color even rows',

@@ -69,15 +112,5 @@ //xpColMap:'Columns map to',

xpSQLId:'Enable identity insert',
DownloadEntity:"Download {0}"
DownloadEntity:'Download {0}'
},
// --- buttons ---
Save:"Save",
SaveAdd:"Save and Add Another",
Cancel:"Cancel",
NoChange:"No Change",
NoX:"No {0}",
// --- many ---
nodata: 'No data.',
// --- filters ---

@@ -84,0 +117,0 @@ filters:{

/*! ***************************************************************************
*
* evol-utility : many-cards.js
* evolutility :: many-cards.js
*
* View many cards
*
* https://github.com/evoluteur/evolutility
* Copyright (c) 2014, Olivier Giulieri

@@ -11,5 +12,3 @@ *

var Evol = Evol || {},
EvoUI = Evol.UI,
EvoDico = Evol.Dico;
var Evol = Evol || {};

@@ -20,9 +19,2 @@ Evol.ViewMany.Cards = Evol.ViewMany.extend({

options: {
style: 'panel-info',
pageSize: 20,
title: '#title', // TODO FIX
selectable: true
},
customize: function () {

@@ -34,3 +26,3 @@ var labels = this.$('h4 > a.evol-nav-id');

}else{
labels.append(EvoUI.icons.customize('id','field'));
labels.append(Evol.UI.iconCustomize('id','field'));
this._custOn=true;

@@ -41,10 +33,16 @@ }

render: function () {
_render: function (models) {
var h = [];
if(this.model && this.model.collection && this.model.collection.length>0){
this._render(h, this.options.mode);
if(models && models.length>0){
var opts = this.options,
uim = opts.uiModel,
pSize = opts.pageSize || 50,
pSummary = this._paginationSummaryHTML(0, pSize, models.length, uim.entity, uim.entities);
h.push('<div class="evol-many-cards">');
this._HTMLcards(h, this.getFields(), pSize, uim.icon);
h.push(pSummary, this._paginationHTML(0, pSize, models.length),
'</div>');
}else{
h.push(EvoUI.HTMLMsg(EvolLang.nodata,'','info'));
h.push(Evol.UI.HTMLMsg(Evol.i18n.nodata,'','info'));
}
this._updateTitle();
this.$el.html(h.join(''));

@@ -54,19 +52,4 @@ return this;

_render: function (h, mode) {
var opts = this.options,
uim = opts.uiModel,
models = this.model.collection.models,
pSize = opts.pageSize || 50,
pSummary = this._paginationSummaryHTML(0, pSize, models.length, uim.entity, uim.entities);
h.push('<div class="evol-many-', mode, '">');
this._HTMLcards(h, this.getFields(), pSize, uim.icon);
if(mode!='charts'){
h.push(pSummary,
this._paginationHTML(0, pSize, models.length));
}
h.push('</div>');
},
_HTMLcards: function (h, fields, pSize, icon) {
var data = this.model.collection.models,
var data = this.collection.models,
rMax = _.min([data.length, pSize]);

@@ -80,21 +63,20 @@ if (rMax > 0) {

v = cRow.get(f.id);
h.push('<div data-id="', cRow.id, '">');
if (i === 0) {
h.push('<h4><a href="#" id="fg-', f.id, '" class="evol-nav-id">');
h.push('<div data-id="', cRow.id, '">',
'<h4><a href="#" id="fg-', f.id, '" class="evol-nav-id">');
if (icon) {
h.push('<img class="evol-table-icon" src="pix/', icon, '">');
}
h.push(this._HTMLField(f,v));
h.push('</a></h4>');
h.push(this._HTMLField(f,v),
'</a></h4></div>');
}else{
//h.push(EvoUI.fieldLabel(f.id,f.label));
h.push(this._HTMLField(f,v));
//h.push(Evol.UI.fieldLabel(f.id,f.label));
h.push('<div>', this._HTMLField(f,v),'</div>');
}
h.push('</div>');
}
h.push('</div>');
}
h.push(EvoUI.html.clearer);
h.push(Evol.UI.html.clearer);
}else{
h.push(EvoUI.HTMLMsg(EvolLang.nodata,'','info'));
h.push(Evol.UI.HTMLMsg(Evol.i18n.nodata,'','info'));
}

@@ -101,0 +83,0 @@ }

/*! ***************************************************************************
*
* evol-utility : many-charts.js
* evolutility :: many-charts.js
*
* View many charts
*
* https://github.com/evoluteur/evolutility
* Copyright (c) 2014, Olivier Giulieri

@@ -11,5 +12,3 @@ *

var Evol = Evol || {},
EvoUI = Evol.UI,
EvoDico = Evol.Dico;
var Evol = Evol || {};

@@ -20,9 +19,2 @@ Evol.ViewMany.Charts = Evol.ViewMany.extend({

options: {
style: 'panel-info',
pageSize: 20,
title: '#title', // TODO FIX
selectable: true
},
events: {

@@ -34,11 +26,8 @@ 'click .evol-field-label .glyphicon-wrench': 'click_customize'

var h = [];
if(this.model && this.model.collection && this.model.collection.length>0){
var opts = this.options,
uim = opts.uiModel,
pSize = opts.pageSize || 50;
if(this.collection && this.collection.length>0){
h.push('<div class="evol-many-', this.viewName, '">');
this._HTMLcharts(h, this.getFields(), pSize, uim.icon);
this._HTMLcharts(h, this.options.style);
h.push('</div>');
}else{
h.push(EvoUI.HTMLMsg(EvolLang.nodata,'','info'));
h.push(Evol.UI.HTMLMsg(Evol.i18n.nodata,'','info'));
}

@@ -50,36 +39,45 @@ this._updateTitle();

_HTMLcharts: function (h) {
_HTMLcharts: function (h, style) {
var that=this,
uiModel =this.options.uiModel,
model = this.model,
models = model.collection.models,
chartFields = EvoDico.fields(uiModel, function(f){
return (f.type==EvoDico.fieldTypes.lov || f.type==EvoDico.fieldTypes.bool);
EvoUI = Evol.UI,
EvoDico = Evol.Dico,
fTypes = EvoDico.fieldTypes,
uiModel = this.options.uiModel,
models = this.collection.models,
chartFields = EvoDico.getFields(uiModel, function(f){
return (f.type==fTypes.lov || f.type==fTypes.bool || f.type==fTypes.integer);
});
_.each(chartFields, function(f){
var groups = _.countBy(models, function(m) {
return m.get(f.id);
});
var groupData = groups,
data=[],
labels=[];
for(var dataSetName in groupData) {
var g=groupData[dataSetName];
data.push(g);
if(EvoDico.isTypeDateOrTime(f)){
labels.push(that._lovText(f,dataSetName)+' ('+g+')');
}else if(f.type==EvoDico.fieldTypes.lov){
labels.push(that._lovText(f,dataSetName)+' ('+g+')');
if(chartFields && chartFields.length){
_.each(chartFields, function(f){
var groups = _.countBy(models, function(m) {
return m.get(f.id);
});
var groupData = groups,
data=[],
labels=[];
for(var dataSetName in groupData) {
var g=groupData[dataSetName];
data.push(g);
if(f.type==fTypes.lov){
//var lov=[];
//_.each(f.list, function(item){
//});
labels.push(EvoDico.lovText(that._hashLov, f,dataSetName)+' ('+g+')');
//labels.push(EvoDico.lovText(that._hashLov, f,dataSetName)+' ('+g+')');
}else{
labels.push(dataSetName+' ('+g+')');
}
}
var entityName=EvoUI.capFirstLetter(uiModel.entities);
if(f.type==fTypes.lov){
h.push(EvoUI.Charts.Pie(Evol.i18n.getLabel('charts.aByB',entityName,f.label), data, labels, style));
}else{
labels.push(dataSetName+' ('+g+')');
h.push(EvoUI.Charts.Bars(Evol.i18n.getLabel('charts.aB',entityName,f.label), data, labels, style));
}
}
var entityName=EvoUI.capFirstLetter(uiModel.entities);
if(f.type==EvoDico.fieldTypes.lov){
h.push(EvoUI.Charts.Pie(entityName + ' by ' + f.label, data, labels));
}else{
h.push(EvoUI.Charts.Bars(entityName + ': ' + f.label, data, labels));
}
});
});
}else{
h.push(EvoUI.HTMLMsg(Evol.i18n.nochart, Evol.i18n.nochart));
}
h.push(EvoUI.html.clearer);

@@ -86,0 +84,0 @@ }

/*! ***************************************************************************
*
* evol-utility : many-list.js
* evolutility :: many-list.js
*
* View many list
*
* https://github.com/evoluteur/evolutility
* Copyright (c) 2014, Olivier Giulieri

@@ -11,5 +12,3 @@ *

var Evol = Evol || {},
EvoUI = Evol.UI,
EvoDico = Evol.Dico;
var Evol = Evol || {};

@@ -27,46 +26,41 @@ Evol.ViewMany.List = Evol.ViewMany.extend({

render: function () {
var h = [];
if(this.model && this.model.collection && this.model.collection.length>0){
this._render(h, this.options.mode);
}else{
h.push(EvoUI.HTMLMsg(EvolLang.nodata,'','info'));
}
this._updateTitle();
this.$el.html(h.join(''));
return this;
},
_render: function (h, mode) {
var opts = this.options,
_render: function (models) {
var h = [],
fields = this.getFields(),
opts = this.options,
uim = opts.uiModel,
models = this.model.collection.models,
pSize = opts.pageSize || 50,
pSummary = this._paginationSummaryHTML(0, pSize, models.length, uim.entity, uim.entities);
h.push('<div class="evol-many-', mode, '">');
this['_HTML' + mode.replace(/-/g,'_')](h, this.getFields(), pSize, uim.icon);
if(mode!='charts'){
h.push(pSummary,
this._paginationHTML(0, pSize, models.length));
}
h.push('</div>');
},
_HTMLlist: function (h, fields, pSize, icon) {
h.push('<div class="panel ',this.options.style,'">');
h.push('<table class="table table-bordered table-hover"><thead>');
this._models=models;
h.push('<div class="evol-many-list">',
//'<div class="panel ',this.options.style,'">',
'<table class="table table-bordered table-hover"><thead>');
for (var i=0; i<fields.length; i++) {
this._renderListHeader(h, fields[i]);
this._HTMLlistHeader(h, fields[i]);
}
h.push('</thead><tbody>');
this._HTMLlistbody(h, fields, pSize, icon);
h.push('</tbody></table></div>');
this._HTMLlistBody(h, fields, pSize, uim.icon);
h.push('</tbody></table>', //</div>
pSummary, this._paginationHTML(0, pSize, models.length),
'</div>');
this.$el.html(h.join(''));
},
_HTMLlistbody: function(h, fields, pSize, icon){
var data = this.model.collection.models,
renderBody: function(models){
var h=[],
fields = this.getFields(),
opts = this.options,
uim = opts.uiModel,
pSize = opts.pageSize || 50;
this._HTMLlistBody(h, fields, pSize, uim.icon);
this.$('.table > tbody').html(h.join(''));
},
_HTMLlistBody: function(h, fields, pSize, icon){
var data = this._models,
rMax = _.min([data.length, pSize]);
if (rMax > 0) {
for (var r = 0; r < rMax; r++) {
this._HTMLlistrow(h, fields, data[r], icon);
this._HTMLlistRow(h, fields, data[r], icon);
}

@@ -76,3 +70,3 @@ }

_HTMLlistrow: function(h, fields, model, icon){
_HTMLlistRow: function(h, fields, model, icon){
h.push('<tr data-id="', model.cid, '">');

@@ -83,10 +77,15 @@ for (var i=0; i<fields.length; i++) {

h.push('<td>');
if (i === 0) {
if(i===0){
h.push('<a href="javascript:void(0)" id="fv-', f.id, '" class="evol-nav-id">');
if (icon) {
if(_.isFunction(icon) ){
h.push('<img class="evol-table-icon" src="pix/', icon(model), '">');
}else if(icon!==''){
h.push('<img class="evol-table-icon" src="pix/', icon, '">');
}
if(v===''){
v='('+model.id+')';
}
}
h.push(this._HTMLField(f,v));
if (i === 0) {
if(i===0){
h.push('</a>');

@@ -99,10 +98,9 @@ }

_renderListHeader: function (h, field) {
_HTMLlistHeader: function (h, field) {
h.push('<th><span id="', field.id, '-lbl">',
field.label,
field.labellist || field.label,
'<span class="evol-sort-icons" data-fid="',field.id,'">',
EvoUI.icon('chevron-up'),
EvoUI.icon('chevron-down'),
'</span></span></th>'
);
Evol.UI.icon('chevron-up'),//'sort-by-alphabet'
Evol.UI.icon('chevron-down'),//'sort-by-alphabet-alt'
'</span></span></th>');
}

@@ -109,0 +107,0 @@

/*! ***************************************************************************
*
* evol-utility : many.js
* evolutility :: many.js
*
* View many
*
* https://github.com/evoluteur/evolutility
* Copyright (c) 2014, Olivier Giulieri

@@ -11,5 +12,3 @@ *

var Evol = Evol || {},
EvoUI = Evol.UI,
EvoDico = Evol.Dico;
var Evol = Evol || {};

@@ -19,2 +18,3 @@ Evol.ViewMany = Backbone.View.extend({

cardinality: 'n',
_hashLov: {},

@@ -24,3 +24,3 @@ options: {

pageSize: 20,
title: '#title', // TODO FIX
titleSelector: '#title',
selectable: true

@@ -30,4 +30,4 @@ },

events: {
'click a.evol-nav-id': 'click_navigate',
'click .evol-sort-icons > span': 'click_sort',
'click .evol-nav-id': 'click_navigate',
'click .evol-sort-icons > i': 'click_sort',
'click .button.edit': 'click_pagination',

@@ -39,13 +39,76 @@ 'click .evol-field-label .glyphicon-wrench': 'click_customize'

var that=this;
this.options.mode=opts.mode;
this.options.uiModel=opts.uiModel;
if(this.model){
this.model.collection.on('change', function(model){
this.options=_.extend(this.options, opts);
this._filter=[];
if(this.collection){
this.collection.on('change', function(model){
that.render();
});
}
//if(){
this._custOn=false;
},
//}
render:function(){
var models=this.collection.models;
if(this.collection.length){
if(this._filter.length){
var that=this;
models=models.filter(function(model){
var filters=that._filter,
want=true;
for(var i= 0, iMax=filters.length;i<iMax && want;i++){
var filter=filters[i],
vf=filter.value.value,
fv=model.get(filter.field.value);
if(fv===undefined){
fv='';
}
switch(filter.operator.value){
case 'eq':
want=vf===fv;
break;
case 'ne':
want=vf!==fv;
break;
case 'sw':
want=fv.indexOf(vf)===0;
break;
case 'ct':
want=fv.indexOf(vf)>-1;
break;
case 'fw':
want=fv.indexOf(vf)===fv.length-vf.length;
break;
case 'null':
want=fv==='' || fv===undefined;
break;
case 'nn':
want=fv!=='' || fv!==undefined;
break;
case 'in':
want= _.contains(vf.split(','),fv);
break;
case 1:
want=fv;
break;
case 0:
want=!fv;
break;
}
}
return want;
});
}
this._render(models);
}else{
this.$el.html(Evol.UI.HTMLMsg(Evol.i18n.nodata,'','info'));
}
this._updateTitle();
return this;
},
_render:function(models){
alert('_render must be overwritten');
},
customize: function () {

@@ -55,38 +118,51 @@ var labels = this.$('th > span');

labels.find('i').remove();
this._custOn=false;
}else{
labels.append(EvoUI.icons.customize('id','field'));
this._custOn=true;
labels.append(Evol.UI.iconCustomize('id','field'));
}
this._custOn=!this._custOn;
return this;
},
render: function () {
var h = [];
if(this.model && this.model.collection && this.model.collection.length>0){
this.renderList(h, this.options.mode);
}else{
h.push(EvoUI.HTMLMsg(EvolLang.nodata,'','info'));
setModel: function(model) {
if(model && model.collection){
this.collection = model.collection;
}
this._updateTitle();
this.$el.html(h.join(''));
this.render();
return this;
},
setModel: function(model) {
this.model = model;
setCollection: function(collection){
this.collection = collection;
this.render();
return this;
},
updateModel: function () {
alert('updateModel');
getCollection: function(){
return this.collection;
},
setFilter: function(filter){
this._filter=filter;
return this;
},
getFilter: function(filter){
return this._filter;
},
//updateModel: function () {
// alert('updateModel');
//},
_updateTitle: function (){
//$(this.options.title).html(this.model.get('title'));
$(this.options.titleSelector).html(this.getTitle());
},
getTitle: function (){
return Evol.UI.capFirstLetter(this.options.uiModel.entities);
},
getFields: function (){
if(!this._fields){
this._fields=EvoDico.fields(this.options.uiModel, function(f){
this._fields=Evol.Dico.getFields(this.options.uiModel, function(f){
return f.viewmany;

@@ -107,35 +183,11 @@ });

_hashLov: {},
_lovText:function(f,v){
if(('list' in f) && f.list.length>0){
if(!(f.id in this._hashLov)){
this._hashLov[f.id]={};
}
var hashLov = this._hashLov[f.id];
if(v in hashLov){
return hashLov[v];
}else{
_.each(f.list,function(obj){
if(obj.id==v){
var txt=obj.text;
if(obj.icon){
txt='<img src="'+obj.icon+'"> '+txt;
}
hashLov[v]=obj.text;
return obj.text;
}
});
}
}
return '';
},
_HTMLField: function(f,v){
var fTypes = Evol.Dico.fieldTypes;
switch(f.type){
case EvoDico.fieldTypes.bool:
case fTypes.bool:
if (v==='true' || v=='1') {
return EvoUI.icon('ok');
return Evol.UI.icon('ok');
}
break;
case EvoDico.fieldTypes.lov:
case fTypes.lov:
if (v !== '') {

@@ -145,27 +197,21 @@ //if(f.icon && f.list & f.list[0].icon){

//}else{
return this._lovText(f,v);
return Evol.Dico.lovText(this._hashLov, f, v);
//}
}
break;
case EvoDico.fieldTypes.date:
case EvoDico.fieldTypes.time:
case EvoDico.fieldTypes.datetime:
if (v !== '') {
var myDate=new Date(v);
if(_.isDate(myDate)){
var dv='';
//return myDate.toLocaleDateString("en-US");
if(f.type!=EvoDico.fieldTypes.time){
dv+=EvoUI.formatDate(myDate);
}
if(f.type==EvoDico.fieldTypes.datetime){
dv+=' ';
}
if(f.type!=EvoDico.fieldTypes.date){
dv+=EvoUI.formatTime(myDate);
}
return dv;
}
case fTypes.date:
case fTypes.time:
case fTypes.datetime:
return Evol.UI.formatDateTime(v);
case fTypes.pix:
if (v.length) {
return Evol.UI.input.img(f.id, v);
}
break;
case fTypes.money:
var nv=parseFloat(v);
if (!isNaN(nv)) {
return '$'+nv.toFixed(2);
}
break;
default:

@@ -211,14 +257,21 @@ return v;

sortList: function(f, down){
var collec=this.model.collection;
if(f.type==EvoDico.fieldTypes.text || f.type==EvoDico.fieldTypes.txtm || f.type==EvoDico.fieldTypes.email){
collec.comparator = EvoDico.bbComparatorText(f.id);
}else{
collec.comparator = EvoDico.bbComparator(f.id);
var collec=this.collection,
ft=Evol.Dico.fieldTypes;
if(collec!==undefined){
if(f.type==ft.text || f.type==ft.txtm || f.type==ft.email){
collec.comparator = Evol.Dico.bbComparatorText(f.id);
}else{
collec.comparator = Evol.Dico.bbComparator(f.id);
}
collec.sort();
if(down){
collec.models.reverse();
}
if(this.renderBody){
this.renderBody(collec.models);
}else{
this.render();
}
this.$el.trigger('list.sort', {id: f.id, direction:down?'down':'up'});
}
collec.sort();
if(down){
collec.models.reverse();
}
this.render(); //todo: renderBody
this.$el.trigger('list.sort', {id: f.id, direction:down?'down':'up'});
},

@@ -251,3 +304,3 @@

EvoDico.showDesigner(id, eType, $e);
Evol.Dico.showDesigner(id, eType, $e);
this.$el.trigger(eType+'.customize', {id: id, type:eType});

@@ -254,0 +307,0 @@ }

/*! ***************************************************************************
*
* evol-utility : one-edit.js
* evolutility :: one-edit.js
*
* View one edit
*
* https://github.com/evoluteur/evolutility
* Copyright (c) 2014, Olivier Giulieri

@@ -11,5 +12,3 @@ *

var Evol = Evol || {},
EvoUI = Evol.UI,
EvoDico = Evol.Dico;
var Evol = Evol || {};

@@ -23,63 +22,9 @@ Evol.ViewOne.Edit = Evol.ViewOne.extend({

var h = [];
this.renderEdit(h, 'edit');
this.renderEdit(h);
this.$el.html(h.join(''));
this.setData(this.model);
this._updateTitle();
this.custOn=false;
return this;
},
renderEdit: function (h) {
// EDIT and VIEW forms
var iTab = -1,
iPanel = -1,
opts = this.options,
elems = opts.uiModel.elements,
mode = 'edit';
h.push('<div class="evo-one-',mode,'">');
for (var i = 0, iMax = elems.length; i < iMax; i++) {
var p = elems[i];
switch (p.type) {
case 'tab':
if (iPanel > 0) {
h.push('</div>');
iPanel = -1;
}
if (iTab < 0) {
h.push(EvoUI.html.clearer);
this.renderTabs(h, elems);
h.push('<div class="tab-content">');
}
iTab++;
h.push('<div id="evol-tab-', i, '" class="tab-pane', (i === 1 ? ' active">' : '">'));
this.renderTab(h, p, mode);
if (iTab == iMax - 1) {
h.push('</div>');
}
break;
case 'panel':
if (iPanel < 0) {
h.push('<div class="evol-pnls">');
iPanel = 1;
}
this.renderPanel(h, p, 'pe-' + i, mode);
break;
case 'panel-list':
if (iPanel < 0) {
h.push('');
iPanel = 1;
}
this.renderPanelList(h, p, 'pe-' + i, mode);
break;
}
}
if (iPanel > 0) {
h.push('</div>');
}
h.push('</div>');
this._renderButtons(h, mode);
this._updateTitle();
}
});
/*! ***************************************************************************
*
* evol-utility : one-json.js
* evolutility :: one-json.js
*
* View one json
*
* https://github.com/evoluteur/evolutility
* Copyright (c) 2014, Olivier Giulieri

@@ -11,5 +12,3 @@ *

var Evol = Evol || {},
EvoUI = Evol.UI,
EvoDico = Evol.Dico;
var Evol = Evol || {};

@@ -19,9 +18,6 @@ Evol.ViewOne.JSON = Evol.ViewOne.extend({

events: {
'click > .evol-buttons > button': 'click_button',
'click .evol-title-toggle': 'click_toggle',
'click .evol-field-label .glyphicon-wrench': 'click_customize'
'click > .evol-buttons > button': 'click_button'
},
viewName: 'json',
prefix: 'oj',

@@ -31,4 +27,4 @@ render: function () {

if(this.model){
var jsonStr=JSON.stringify(this.model.toJSON(), null, 2);
h.push(EvoUI.inputTextMJSON('',jsonStr,10));
var jsonStr=JSON.stringify(this.model, null, 2);
h.push(Evol.UI.input.textMJSON('',jsonStr,10));
}

@@ -38,3 +34,2 @@ this._renderButtons(h, 'json');

this.setData(this.model);
this._updateTitle();
this.custOn=false;

@@ -50,6 +45,5 @@ return this;

setData: function (m) {
var that=this,
prefix='#'+ that.prefix + '-';
this.$el.children('textarea').val(JSON.stringify(m, null, 2));
this._updateTitle();
this.$el.children('textarea')
.val(JSON.stringify(m, null, 2));
return this._updateTitle();
},

@@ -56,0 +50,0 @@

/*! ***************************************************************************
*
* evol-utility : one-mini.js
* evolutility :: one-mini.js
*
* View one mini
*
* https://github.com/evoluteur/evolutility
* Copyright (c) 2014, Olivier Giulieri

@@ -11,5 +12,3 @@ *

var Evol = Evol || {},
EvoUI = Evol.UI,
EvoDico = Evol.Dico;
var Evol = Evol || {};

@@ -35,6 +34,5 @@ Evol.ViewOne.Mini = Evol.ViewOne.extend({

h = [];
this.renderEdit(h, mode);
this._renderEdit(h, mode);
this.$el.html(h.join(''));
this.setData(this.model);
this._updateTitle();
this.custOn=false;

@@ -44,3 +42,3 @@ return this;

renderEdit: function (h, mode) {
_renderEdit: function (h, mode) {
// EDIT and VIEW forms

@@ -50,10 +48,9 @@ var opts = this.options,

miniUIModel= {
type: 'panel', class:'evo-mini-holder', label: EvoUI.capFirstLetter(opts.uiModel.entity), width: 100,
type: 'panel', class:'evol-mini-holder', label: Evol.UI.capFirstLetter(opts.uiModel.entity), width: 100,
elements: flds
};
this.renderPanel(h,miniUIModel,'evo-one-mini',mode);
this.renderPanel(h, miniUIModel, 'evol-one-mini', mode);
this._renderButtons(h, mode);
this._updateTitle();
}
});
/*! ***************************************************************************
*
* evol-utility : one.js
* evolutility :: one.js
*
* View one
*
* https://github.com/evoluteur/evolutility
* Copyright (c) 2014, Olivier Giulieri

@@ -11,5 +12,3 @@ *

var Evol = Evol || {},
EvoUI = Evol.UI,
EvoDico = Evol.Dico;
var Evol = Evol || {};

@@ -19,3 +18,3 @@ Evol.ViewOne = Backbone.View.extend({

events: {
'click > .evol-buttons > button': 'click_button',
'click .evol-buttons > button': 'click_button',
'click .evol-title-toggle': 'click_toggle',

@@ -33,11 +32,9 @@ 'click ul.evol-tabs > li > a': 'click_tab',

style: 'panel-info',
titleSelector: ''
titleSelector: '#title'
},
initialize: function (opts) {
var that=this,
mode=opts.mode;
this.options.mode=mode;
this.options.uiModel=opts.uiModel;
var that=this;
_.extend(this.options, opts);
this._uTitle=this.options.titleSelector!==undefined && this.options.titleSelector!=='';
if(this.model){

@@ -54,10 +51,5 @@ this.model.on('change', function(model){

h = [];
if(mode==='json'){
this.renderJSON(h, mode);
}else{
this.renderEdit(h, mode);
}
this.renderEdit(h, mode);
this.$el.html(h.join(''));
this.setData(this.model);
this._updateTitle();
this.custOn=false;

@@ -67,5 +59,5 @@ return this;

getFields: function (condition){
getFields: function (){
if(!this._fields){
this._fields=EvoDico.fields(this.options.uiModel,condition);
this._fields=Evol.Dico.getFields(this.options.uiModel, this.getFieldsCondition);
this._fieldHash={};

@@ -80,14 +72,30 @@ var that=this;

getSubCollecs: function (){
if(!this._subCollecs){
this._subCollecs=Evol.Dico.getSubCollecs(this.options.uiModel);
}
return this._subCollecs;
},
setModel: function(model) {
this.model = model;
this.clearMessages();
this.setData(model);
return this
.clearMessages()
.setData(model);
},
getModel:function(model) {
return this.model;
},
setUIModel: function(uimodel) {
this.options.uiModel = uimodel;
var d=this.getData();
this.render()
return this
.render()
.setData(d);
},
getUIModel: function(uimodel) {
return this.options.uiModel;
},

@@ -101,8 +109,15 @@ modelUpdate: function (model) {

getTitle: function(){
if(this.model){
var lf=this.options.uiModel.leadfield;
return _.isFunction(lf)?lf(this.model):this.model.get(lf);
}else{
return Evol.UI.capFirstLetter(this.options.uiModel.entity);
}
},
getData: function () {
var that = this,
vs = {},
fs = this.getFields();
_.each(fs, function(f){
vs = {};
_.each(this.getFields(), function(f){
vs[f.id]=that.getFieldValue(f);

@@ -113,29 +128,46 @@ });

setData: function (m) {
var fs = this.getFields(),
that=this,
$f,
prefix='#'+ that.prefix + '-';
_.each(fs, function (f) {
$f=that.$(prefix + f.id);
if(m){
switch(f.type) {
case 'boolean':
$f.prop('checked',m.get(f.id));
break;
default:
$f.val(m.get(f.id));
setData: function (model) {
if(model!==undefined && model!==null){
var fs = this.getFields(),
that=this,
fTypes = Evol.Dico.fieldTypes,
$f, fv,
prefix='#'+ that.prefix + '-',
subCollecs=this.getSubCollecs();
_.each(fs, function (f) {
$f=that.$(prefix + f.id);
fv=model.get(f.id);
if(model){
switch(f.type) {
case fTypes.lov:
$f.children().removeAttr('selected')
.filter('[value='+fv+']')
.attr('selected', true);
break;
case fTypes.bool:
$f.prop('checked', fv);
break;
case fTypes.pix:
var newPix=(fv!=='')?('<img src="'+fv+'" class="img-thumbnail">'):('<p class="">'+Evol.i18n.nopix+'</p>');
$f.val(fv)
.prev().remove();
$f.before(newPix);
break;
default:
$f.val(fv);
}
}
});
if(subCollecs && subCollecs.length>0){
_.each(subCollecs, function (sc) {
var h=[];
that._renderPanelListBody(h, sc);
that.$('[data-pid="'+sc.id+'"] tbody')
.html(h.join(''));
});
}
});
this._updateTitle();
}
return this._updateTitle();
},
_updateTitle: function (){/*
var selector=this.options.titleSelector
if(selector && selector!=''){
$(selector).html(this.model.get('title'));
}*/
},
clear: function () {

@@ -146,13 +178,13 @@ var fs = this.getFields(),

prefix='#'+ that.prefix + '-';
this.clearMessages();
_.each(fs, function (f) {
$f=that.$(prefix + f.id);
switch(f.type) {
case 'boolean':
$f.prop('checked', f.defaultvalue || '');
break;
default:
$f.val(f.defaultvalue || '');
}
});
this.clearMessages();
_.each(fs, function (f) {
$f=that.$(prefix + f.id);
switch(f.type) {
case 'boolean':
$f.prop('checked', f.defaultvalue || '');
break;
default:
$f.val(f.defaultvalue || '');
}
});
return this;

@@ -162,10 +194,17 @@ },

setFieldValue: function (fid, value){
this.$('#'+this.fieldViewId(fid)).val(value);
this.$('#'+this.fieldViewId(fid))
.val(value);
return this;
},
getFieldValue: function (f){
var $f=this.$('#'+this.prefix+'-'+f.id);
var $f=this.$('#'+this.fieldViewId(f.id));
switch(f.type) {
case EvoDico.fieldTypes.bool:
case Evol.Dico.fieldTypes.bool:
return $f.prop('checked');
case Evol.Dico.fieldTypes.integer:
return parseInt($f.val(),10);
case Evol.Dico.fieldTypes.decimal:
case Evol.Dico.fieldTypes.money:
return parseFloat($f.val());
default:

@@ -190,11 +229,11 @@ return $f.val();

},
_renderButtons: function (h, mode) {
h.push(
EvoUI.html.clearer,
var css=Evol.UI.getSizeCSS(this.options.size);
h.push(Evol.UI.html.clearer,
'<div class="evol-buttons">',
EvoUI.inputButton('cancel', EvolLang.Cancel, 'btn-default'),
EvoUI.inputButton('save', EvolLang.Save, 'btn-primary')
);
Evol.UI.input.button('cancel', Evol.i18n.Cancel, 'btn-default'+css),
Evol.UI.input.button('save', Evol.i18n.Save, 'btn-primary'+css));
if (this.options.button_addAnother && mode!=='json') {
h.push(EvoUI.inputButton('save-add', EvolLang.SaveAdd, 'btn-default'));
h.push(Evol.UI.input.button('save-add', Evol.i18n.SaveAdd, 'btn-default'+css));
}

@@ -212,7 +251,7 @@ h.push('</div>');

if(mode==='mini'){
var flds = EvoDico.fields(opts.uiModel,function(f){
var flds = Evol.Dico.getFields(opts.uiModel,function(f){
return f.searchlist || f.required || f.mini;
},opts.mode),
miniUIModel= {
type: 'panel', class:'evo-mini-holder', label: EvoUI.capFirstLetter(opts.uiModel.entity), width: 100,
type: 'panel', class:'evol-mini-holder', label: Evol.UI.capFirstLetter(opts.uiModel.entity), width: 100,
elements: flds

@@ -233,3 +272,3 @@ };

if (iTab < 0) {
h.push(EvoUI.html.clearer);
h.push(Evol.UI.html.clearer);
this.renderTabs(h, elems);

@@ -250,5 +289,6 @@ h.push('<div class="tab-content">');

}
this.renderPanel(h, p, 'pe-' + i, mode);
this.renderPanel(h, p, 'p-' + p.id, mode);
break;
case 'panel-list':
this._hasSubCollec=true;
if (iPanel < 0) {

@@ -258,3 +298,3 @@ h.push('');

}
this.renderPanelList(h, p, 'pe-' + i, mode);
this.renderPanelList(h, p, mode);
break;

@@ -269,3 +309,2 @@ }

this._renderButtons(h, mode);
this._updateTitle();
},

@@ -293,10 +332,10 @@

h.push('<div class="evol-pnls">');
_.each(t.elements, function (elem, idx) {
if (elem.type === 'panel-list') {
that.renderPanelList(h, elem, 'pl-' + idx, mode);
_.each(t.elements, function (uip, idx) {
if (uip.type === 'panel-list') {
that.renderPanelList(h, uip, mode);
} else {
that.renderPanel(h, elem, 'pl-' + idx, mode);
that.renderPanel(h, uip, uip.id || 'pl-'+idx, mode);
}
});
h.push(EvoUI.html.clearer, '</div></div>');
h.push(Evol.UI.html.clearer, '</div></div>');
},

@@ -306,7 +345,12 @@

var that = this;
h.push('<div data-p-width="', p.width, '" class="evol-pnl');
if(mode==='mini'){
h.push('<div data-p-width="', p.width, '" class="w-100 evol-pnl ', (p.class || ''), '">',
'<div class="panel ', this.options.style, '">',
EvoUI.HTMLPanelLabel(p.label, pid, 'PanelLabel'),
'<fieldset data-pid="', pid, '">');
h.push(' w-100 ', (p.class || ''), '">');
}else{
h.push(' pull-left" style="width:', p.width, '%">');
}
h.push('<div class="panel ', this.options.style, '">',
Evol.UI.HTMLPanelLabel(p.label, pid, 'PanelLabel'),
'<fieldset data-pid="', pid, '">');
if(mode==='mini'){
_.each(p.elements, function (elem) {

@@ -318,6 +362,2 @@ h.push('<div class="pull-left evol-fld w-100">');

}else{
h.push('<div style="width:', p.width, '%" data-p-width="', p.width, '" class="pull-left evol-pnl">',
'<div class="panel ', this.options.style, '">',
EvoUI.HTMLPanelLabel(p.label, pid, 'PanelLabel'),
'<fieldset data-pid="', pid, '">');
_.each(p.elements, function (elem) {

@@ -332,48 +372,55 @@ h.push('<div style="width:', parseInt(elem.width, 10), '%" class="pull-left evol-fld">');

renderPanelList: function (h, p, pid, mode) {
h.push('<div style="width:', p.width, '%" class="pull-left evol-pnl">',
renderPanelList: function (h, p, mode) {
h.push('<div style="width:', p.width, '%" class="evol-pnl pull-left" data-pid="', p.id,'">',
'<div class="panel ', this.options.style, '">',
EvoUI.HTMLPanelLabel(p.label, pid, 'PanelLabel'),
'<table width="100%" class="table-striped"><tr>');
Evol.UI.HTMLPanelLabel(p.label, p.id, 'PanelLabel'),
'<table class="table"><thead><tr>'); // table-striped
_.each(p.elements, function (elem) {
h.push('<th>', elem.label, '</th>');
});
h.push('</tr><tr>');
_.each(p.elements, function (elem) {
h.push('<td>', elem.label, '</td>');
});
h.push('</tr></table></div></div>');
h.push('</tr></thead><tbody>');
this._renderPanelListBody(h,p,mode);
h.push('</tbody></table></div></div>');
},
_renderPanelListBody: function (h,p,mode){
var vs = this.model.get(p.attr);
if(vs && vs.length>0){
_.each(vs, function(row){
h.push('<tr>');
_.each(p.elements, function (elem) {
if(row[elem.id]){
h.push('<td>',row[elem.id],'</td>'); // TODO row.elem.attr as spec
}else{
h.push('<td></td>');
}
});
h.push('</tr>');
});
}else{
h.push('<tr><td colspan="',p.elements.length,'" class="evol-pl-nodata">',Evol.i18n.nodata,'</td></tr>');
}
},
renderField: function (h, fld, mode) {
function cleanId(id) {
return id.toLocaleLowerCase()
.replace(/ /g, '_')
.replace(/\(/g, '')
.replace(/\)/g, '');
}
var types=EvoDico.fieldTypes,
fid, fv, fwidth;
if (fld.id && fld.id !== '') {
fid = fld.id;
} else {
fid = cleanId(fld.label);
fld.id = fid;
}
if(this.model && this.model.has(fid)){
if (mode != 'new') {
fv = this.model.get(fid);
}else if (fld.defaultvalue){
fv = fld.defaultvalue;
var EvoUI = Evol.UI,
types=Evol.Dico.fieldTypes,
fid = this.fieldViewId(fld.id),
fv,
fwidth,
size = this.options.size;
if(this.model && this.model.has(fld.id)){
if (mode !== 'new') {
fv = this.model.get(fld.id);
}else{
fv = '';
fv = fld.defaultvalue || '';
}
}
fid = this.fieldViewId(fid);
// --- field label ---
if(mode==='mini'){
fwidth=fld.width;
fld.width=100;
h.push('<div class="evo-mini-label">');
h.push('<div class="evol-mini-label">');
this.renderFieldLabel(h, fld, mode);
h.push('</div><div class="evo-mini-content">');
h.push('</div><div class="evol-mini-content">');
}else{

@@ -388,3 +435,3 @@ this.renderFieldLabel(h, fld, mode);

case types.text:
h.push(EvoUI.inputText(fid, fv, fld));
h.push(EvoUI.input.text(fid, fv, fld, null, size));
break;

@@ -395,5 +442,4 @@ case types.email:

} else {
//h.push('<div class="input-group"><span class="input-group-addon">@</span>');
h.push(EvoUI.inputText(fid, fv, fld.maxlength));
//h.push('</div>');
h.push('<div class="input-group">', EvoUI.input.typeFlag('@'),
EvoUI.input.text(fid, fv, fld.maxlength), '</div>');
}

@@ -405,3 +451,3 @@ break;

} else {
h.push(EvoUI.inputText(fid, fv, fld.maxlength));
h.push(EvoUI.input.text(fid, fv, fld.maxlength));
}

@@ -411,10 +457,14 @@ break;

case types.dec:
h.push(EvoUI.inputTextInt(fid, fv));
h.push(EvoUI.input.textInt(fid, fv));
break;
case types.money:
h.push('<div class="input-group">', EvoUI.input.typeFlag('$'),
EvoUI.input.textInt(fid, fv), '</div>');
break;
case types.bool:
h.push(EvoUI.inputCheckbox(fid, fv));
h.push(EvoUI.input.checkbox(fid, fv));
break;
case types.txtm:
case types.html:
////// fv = HttpUtility.HtmlEncode(fv);
// fv = HttpUtility.HtmlEncode(fv);
if (fld.height === null) {

@@ -428,61 +478,33 @@ fld.height = 5;

}
h.push(EvoUI.inputTextM(fid, fv, fld.maxlength, fld.height));
h.push(EvoUI.input.textM(fid, fv, fld.maxlength, fld.height));
break;
case types.date:
h.push(EvoUI.inputDate(fid, fv));
h.push(EvoUI.input.date(fid, fv));
break;
case types.datetime:
h.push(EvoUI.inputDateTime(fid, fv));
h.push(EvoUI.input.dateTime(fid, fv));
break;
case types.time:
h.push(EvoUI.inputTime(fid, fv));
h.push(EvoUI.input.time(fid, fv));
break;
case types.color:
h.push(EvoUI.inputColor(fid, fv));
h.push(EvoUI.input.color(fid, fv));
break;
case types.lov:
h.push(EvoUI.inputLOV(fid, fv, '', fld.list || []));
h.push(EvoUI.input.select(fid,'',true, fld.list));
break;
case types.integer:
h.push(EvoUI.inputTextInt(fid, fv, fld.type, fld.max, fld.min));
h.push(EvoUI.input.textInt(fid, fv, fld.max, fld.min));
break;
// case types.doc:
//case types.doc:
case types.pix:
if(fv===''){
h.push('<p class="">No picture</p>');
if(fv!==''){
h.push('<img src="',fv,'" class="img-thumbnail">');
}else{
h.push('<img src="',fv,'" class="img-thumbnail">');
h.push('<p class="">',Evol.i18n.nopix,'</p>');
}
// h.push(SMALL_tag);
// if (fieldValue != string.Empty)
// h.push("<span class=\"FieldReadOnly\">").Append(fieldValue).Append("</span><br/>");
// if (fType.Equals(types.pix))
// {
// h.push("<br/><img src=\"");
// if (string.IsNullOrEmpty(fieldValue))
// h.push(_PathPixToolbar).Append("imgno.gif\" ID=\"");
// else
// h.push(_PathPix).Append(fieldValue).Append("\" ID=\"");
// h.push(fieldName).Append("img\" alt=\"\" class=\"FieldImg\"/><br/>");
// }
// buffer = string.Format("UP-evol{0}", i);
// h.push(EvoUI.HTMLInputHidden(fieldName + "_dp", string.Empty));
// if (IEbrowser)
// h.push(EvoUI.HTMLLinkShowVanish(buffer, EvolLang.NewUpload));
// if (fieldValue != string.Empty)
// {
// h.push("<br/>&nbsp;<a href=\"Javascript:Evol.");
// string pJS = (fType.Equals(types.pix)) ? "pixM" : "docM";
// h.pushFormat("{0}('{1}')\">{2}</a>", pJS, fieldName, EvolLang.Delete);
// }
// h.push("</small><br/>").Append(EvoUI.HTMLDiv(buffer, !IEbrowser));
// h.push("<input type=\"file\" class=\"Field\" name=\"").AppendFormat("{0}\" id=\"{0}", fieldName);
// h.push("\" value=\"").Append(HttpUtility.HtmlEncode(fieldValue)).Append("\" width=\"120\" onchange=\"e$('").Append(fieldName);
// if (fType.Equals(types.pix))
// h.push("img').src='").Append(_PathPixToolbar).Append("imgupdate.gif';e$('").Append(fieldName);
// h.push("_dp').value=''\"><br/></div>");
h.push(EvoUI.input.text(fid, fv, fld, null, size));
break;
}
}
if(mode==='mini'){

@@ -496,7 +518,7 @@ h.push('</div>');

h.push('<div class="evol-field-label" id="', fld.id, '-lbl"><label class="control-label" for="', fld.id, '">', fld.label);
if (mode != 'view' && fld.required > 0){
h.push('<span class="evol-required">*</span>');
if (mode != 'view' && fld.required){
h.push(Evol.UI.html.required);
}
if (fld.help && fld.help!==''){
h.push(EvoUI.icon('question-sign', ''));
h.push(Evol.UI.icon('question-sign', ''));
}

@@ -506,2 +528,24 @@ h.push('</label></div>');

_updateTitle: function (title){
if(this._uTitle){
var opts=this.options,
selector=opts.titleSelector;
if(selector && selector!==''){
var t,lf=opts.uiModel.leadfield;
if(title){
t=title;
}else if(lf!==undefined && lf!==''){
t=this.getTitle();
}else{
t=Evol.UI.capFirstLetter(opts.uiModel.entities);
}
$(selector).text(t);
this._uTitle=true;
return this;
}
this._uTitle=false;
}
return this;
},
validate: function () {

@@ -511,4 +555,4 @@ var fs = this.getFields();

if (_.isArray(fs)) {
this.$el.trigger('view.validate');
return EvoVal.checkFields(this.$el, fs, this.prefix);
this.$el.trigger('validate'); // TODO decide if use 'view.validate'
return Evol.UI.Validation.checkFields(this.$el, fs, this.prefix);
}

@@ -526,23 +570,2 @@ return false;

commit: function(fnSuccess, fnError){
var msg=this.validate();
if(msg===''){
if(this.options.mode==='new'){
this.model.collection.create(this.getData(), {
success: fnSuccess,
error: fnError
});
}else{
this.model.set(this.getData());
this.model.save({
success: fnSuccess,
error: fnError
});
}
}else{
this.setMessage('Invalid data', msg, 'warning');
}
return this;
},
fieldViewId: function(fid){

@@ -556,3 +579,3 @@ return this.prefix + '-' + fid;

if(this.custOn){
this.$(labelSelector + ' > i, '+ panelSelector + ' > i').remove();
this.$(labelSelector + '>i, '+ panelSelector + '>i').remove();
this.custOn=false;

@@ -563,5 +586,5 @@ }else{

id=$el.attr('for');
$el.append(EvoUI.icons.customize(id,'field'));
$el.append(Evol.UI.iconCustomize(id,'field'));
});
this.$(panelSelector).append(EvoUI.icons.customize('id','panel'));
this.$(panelSelector).append(Evol.UI.iconCustomize('id','panel'));
this.custOn=true;

@@ -573,3 +596,3 @@ }

showHelp:function(id, type, $el){
var fs=EvoDico.fields(this.options.uiModel),
var fs=Evol.Dico.getFields(this.options.uiModel),
fld=_.findWhere(fs,{id:id});

@@ -618,34 +641,10 @@

setMessage: function(title, content,style){
var $msg=this.$('[data-id="msg"]');
if($msg.length){
$msg.html('<strong>'+title+'</strong>'+ content);
}else{
this.$el.prepend(EvoUI.HTMLMsg(title, content,style));
}
},
clearMessage: function(){
var $msg=this.$('[data-id="msg"]')
.fadeOut(300,function(){
$msg.remove();
});
},
clearMessages: function(){
return this.clearErrors().clearMessage();
return this.clearErrors();
},
click_button: function (evt) {
var that=this,
bId = $(evt.currentTarget).attr('id');
var buttonId = $(evt.currentTarget).data('id');
evt.stopImmediatePropagation();
this.commit(function(){
that.setMessage('Record Saved', 'Record was saved.', 'success');
if ((bId=='save-add')) {
//that.new();
}
},function(){
alert('error'); //TODO make it nice looking
});
this.$el.trigger('action', buttonId);
},

@@ -656,3 +655,6 @@

content = $this.closest('.panel-heading').next(),
state = content.data('expState');
state = content.data('expState'),
cssUp = 'glyphicon-chevron-up',
cssDown = 'glyphicon-chevron-down',
css;
evt.preventDefault();

@@ -663,8 +665,8 @@ evt.stopImmediatePropagation();

if (state === 'down') {
$this = this.$('.evol-title-toggle.glyphicon-chevron-down')
.trigger('click');
css = cssDown;
} else {
$this = this.$('.evol-title-toggle.glyphicon-chevron-up')
.trigger('click');
css = cssUp;
}
$this = this.$('.evol-title-toggle.'+css)
.trigger('click');
}else{

@@ -675,4 +677,4 @@ if (state === 'down') {

.data('expState', 'up');
$this.addClass('glyphicon-chevron-up')
.removeClass('glyphicon-chevron-down');
$this.addClass(cssUp)
.removeClass(cssDown);
} else {

@@ -682,4 +684,4 @@ content.slideUp(400, function() {

}).data('expState', 'down');
$this.removeClass('glyphicon-chevron-up')
.addClass('glyphicon-chevron-down');
$this.removeClass(cssUp)
.addClass(cssDown);
}

@@ -727,3 +729,3 @@ }

evt.stopImmediatePropagation();
EvoDico.showDesigner(id, eType, $e);
Evol.Dico.showDesigner(id, eType, $e);
this.$el.trigger(eType+'.customize', {id: id, type:eType});

@@ -734,169 +736,1 @@ }

// ############ Validation #################################################################
// this is some very old code from Evolutility ASP.net version
// TODO rewrite or use another open source
var EvoVal = {
checkMaxLen: function (F, maxL) {
if (F.value.length > maxL){
F.value = F.value.substring(0, maxL - 1);
}
},
checkNum: function (F, t) {
var nv, fv = F.value;
if (t.substring(0, 1) == 'i')
nv = parseInt(fv, 10);
else {
var ln = EvolLang.LOCALE;
if (ln == 'FR' || ln == 'DA')
fv = fv.replace(",", ".");
nv = parseFloat(fv);
}
if (isNaN(nv))
F.value = '';
else if (fv != nv)
F.value = nv;
},
setValidationFlags: function (p, msgf) {
var errlabel = p.find('.text-danger');
if (errlabel.length) {
errlabel.html(msgf);
} else {
p.append('<p class="text-danger">' + msgf + '</p>');
}
p.addClass("has-error");
},
checkFields: function (holder, fds, prefix) {
var evoRegEx = {
email: /^[\w\.\-]+@[\w\.\-]+\.[\w\.\-]+$/,
integer: /^-?\d+$/,
decimalEN: /^\d+(\.\d+)?$/,
decimalFR: /^\d+(\,\d+)?$/,
decimalDA: /^\d+(\,\d+)?$/
};
var msgs = [], ff = null;
for (var i in fds) {
var fd = fds[i],
$f = holder.find('#' + prefix + '-' + fd.id).eq(0),
isHTML = fd.type == 'html';
if (isHTML) {
$f.val(nicEditors.findEditor(f.id).getContent());
}
if ($f.length > 0) {
var noErr = true,
p, msgf;
// Check empty & type
if (fd.required > 0) {
if (isEmpty($f, isHTML)) {
p = $f.parent();
msgf = labMsg(EvolLang.validation.empty);
EvoVal.setValidationFlags(p, msgf);
noErr = false;
} else {
$f.parent().removeClass("control-group error")
.find('.evol-warn-error').remove();
typeCheck();
}
} else {
typeCheck();
}
// Check regexp
if (fd.rg !== null && fd.rg !== undefined) {
var rg = new RegExp(fd.rg);
if (!$f.val().match(rg)) {
p = $f.parent();
msgf = labMsg(EvolLang.validation.reg, fd.rg);
EvoVal.setValidationFlags($f.parent(), msgf);
}
}/*
// Check custom
if (fd.jsv !== null) {
p = eval([fd.jsv, '("', Evol.prefix, fd.id, '","', fd.label, '")'].join(''));
if (p !== null && p.length > 0) {
EvoVal.setValidationFlags($f.parent(), labMsg(p));
}
}*/
// Check min & max
if (noErr) {
var fv = EvoUI.trim($f.val());
if (fv !== '') {
if (fd.max !== null && parseFloat(fv) > fd.max) {
EvoVal.setValidationFlags($f.parent(), labMsg(EvolLang.validation.max, fd.max));
}
if (fd.min !== null && parseFloat(fv) < fd.min) {
EvoVal.setValidationFlags($f.parent(), labMsg(EvolLang.validation.min, fd.min));
}
}
}
}
}
if (msgs.length > 0) {
return [EvolLang.validation.intro, '<ul><li>', msgs.join('<li>'), '</li></ul>'].join('');
} else {
return '';
}
function typeCheck() {
var ft = EvoDico.fieldTypes,
fv = EvoUI.trim($f.val());
if (fv !== '')
switch (fd.type) {
case ft.integer:
case ft.email:
if (!evoRegEx[fd.type].test(fv)) {
EvoVal.setValidationFlags($f.parent(), labMsg(EvolLang[fd.type]));
}
break;
case ft.dec:
var myRegExp = evoRegEx[fd.type + EvolLang.LOCALE];
if (myRegExp === null) {
myRegExp = evoRegEx[fd.type + "EN"]; // default to English with "."
}
if (!myRegExp.test(fv))
EvoVal.setValidationFlags($f.parent(), labMsg(EvolLang[fd.type]));
break;
case ft.date:
case ft.datetime:
//case ft.time:
if ((fv !== '') && (!_.isDate(new Date(fv)))) {
EvoVal.setValidationFlags($f.parent(), labMsg(EvolLang[fd.type]));
}
break;
}
}
function isEmpty($f, isHTML) {
var v, tn = $f.tagName;
if (tn == 'SELECT' && $f.get(0).selectedIndex > -1) {
v = f.options[$f.get(0).selectedIndex].value == "0";
/*} else if (tn == 'TEXTAREA' && isHTML) {
var editor = nicEditors.findEditor(f.id);
if (editor) {
v = editor.getContent().trim()
v = v == '' || v == '<br>';
} else {
v = $f.val().trim() == '';
} */
} else {
v = EvoUI.trim($f.val()) === '';
}
return v;
}
function labMsg(msg, r2) {
var m = msg.replace('{0}', fd.label);
if (r2 !== null) {
m = m.replace('{1}', r2);
}
msgs.push(m);
return m;
}
}
};
/*! ***************************************************************************
*
* evol-utility : toolbar.js
* evolutility :: toolbar.js
*
* https://github.com/evoluteur/evolutility
* Copyright (c) 2014, Olivier Giulieri

@@ -9,6 +10,5 @@ *

var Evol = Evol || {},
EvoUI = Evol.UI,
EvoDico = Evol.Dico;
var Evol = Evol || {};
// toolbar widget which also acts as a controller for all views "one" and "many" as well as actions
Evol.ViewToolbar = Backbone.View.extend({

@@ -18,3 +18,5 @@

'click .nav a': 'click_toolbar',
'list.navigate div': 'click_navigate'
'list.navigate div': 'click_navigate',
'click #XP': 'click_download',
'action > div': 'action_view'
},

@@ -25,3 +27,5 @@

defaultView: 'list',
style: 'normal',
style: 'panel-info',
display: 'tooltip', // tooltip, text, icon, none
titleSelector: '#title',
buttons: {

@@ -39,5 +43,5 @@ // --- views for one ---

del: true,
filter: true,
filter: false,
export: true,
group: true,
group: false,
customize:true

@@ -61,10 +65,9 @@ }

_group:false,
initialize: function (opts) {
var o=this.options;
o.mode=opts.mode;
o.uiModel=opts.uiModel;
o.defaultView=opts.defaultView;
_.extend(this.options, opts);
this.render();
this.$('[data-cid="views"] > li').tooltip();
this.$('.dropdown-toggle').dropdown();
//this.$('[data-toggle]').tooltip();
this.$('.dropdown-toggle').dropdown();//[data-toggle=
},

@@ -76,2 +79,3 @@

this.setView(this.options.defaultView || 'list');
this._viewsIcon=this.$('.glyphicon-eye-open');
},

@@ -83,11 +87,12 @@

endMenu='</ul></li>',
menuDevider='<li role="presentation" class="divider"></li>';
menuDevider='<li role="presentation" class="divider" data-cardi="1"></li>',
menuDeviderCard1='<li role="presentation" class="divider" data-cardi="1"></li>';
function beginMenu(icon){
return ['<li class="dropdown">',
'<a href="#" class="dropdown-toggle" data-toggle="dropdown">',EvoUI.icon(icon),' <b class="caret"></b></a>',
'<ul class="dropdown-menu">'].join('');
function beginMenu(id, icon){
return ['<li class="dropdown" data-id="',id,'">',
'<a href="#" class="dropdown-toggle" data-toggle="dropdown">',Evol.UI.icon(icon),' <b class="caret"></b></a>',
'<ul class="dropdown-menu evo-dropdown-icons">'].join('');
}
function link2h(id, label, icon, cardi, tooltip){
function link2h(id, label, icon, cardi, style){
h.push('<li data-id="',id,'"');

@@ -97,7 +102,7 @@ if(cardi){

}
if(tooltip && tooltip!==''){
h.push(' data-toggle="tooltip" data-placement="bottom" title="" data-original-title="',tooltip,'"');
if(style!=='label'){
h.push(' data-toggle="tooltip" data-placement="bottom" title="" data-original-title="',label,'"');
}
h.push('><a href="#" data-id="',id,'">',EvoUI.icon(icon));
if(label && label!==''){
h.push('><a href="#" data-id="',id,'">',Evol.UI.icon(icon));
if(style!=='tooltip'){
h.push('&nbsp;',label);

@@ -108,29 +113,40 @@ }

function linkOpt2h (id, label, icon, cardi, tooltip){
function linkOpt2h (id, label, icon, cardi){
if(opts.buttons && opts.buttons[id]){
link2h(id, label, icon, cardi, tooltip);
link2h(id, label, icon, cardi, 'tooltip');
}
}
h.push('<div class="evo-toolbar"><ul class="nav nav-pills pull-left" data-cid="main">');
linkOpt2h('list',EvolLang.All,'th-list');
linkOpt2h('new',EvolLang.New,'plus');
linkOpt2h('del',EvolLang.Delete,'trash','1');
//linkOpt2h('filter','Filter','filter','n');
h.push('<div class="evo-toolbar"><ul class="nav nav-pills pull-left" data-id="main">');
linkOpt2h('list',Evol.i18n.All,'th-list');
linkOpt2h('new',Evol.i18n.New,'plus');
linkOpt2h('del',Evol.i18n.Delete,'trash','1');
linkOpt2h('filter','Filter','filter','n');
//linkOpt2h('group','Group','resize-horizontal','n');
//linkOpt2h('export','Export','cloud-download','n');
linkOpt2h('export','Export','cloud-download','n');
//linkOpt2h('selections','','star');
if(opts){
if(opts.toolbar){
link2h('prev','','chevron-left','1');
link2h('next','','chevron-right','1');
h.push('</ul><ul class="nav nav-pills pull-right" data-cid="views">');
linkOpt2h('list','','th-list','n','List');
linkOpt2h('cards','','th-large','n','Cards');
linkOpt2h('charts','','stats','n','Charts');
linkOpt2h('edit','','th','1','All Fields');
linkOpt2h('mini','','th-large','1','Important Fields only');
linkOpt2h('json','','barcode','1','JSON');
/*if(opts.buttons.customize){
//link('customize','','wrench'),
h.push(beginMenu('wrench'));
h.push('</ul><ul class="nav nav-pills pull-right" data-id="views">');
h.push(beginMenu('views','eye-open'));
linkOpt2h('list','List','th-list','n');
linkOpt2h('cards','Cards','th-large','n');
linkOpt2h('charts','Charts','stats','n');
linkOpt2h('edit','All Fields','th','1');
linkOpt2h('mini','Important Fields only','th-large','1');
linkOpt2h('json','JSON','barcode','1');
/*
h.push(menuDeviderCard1);
linkOpt2h('lg','Big','font','1');
linkOpt2h('','Normal','font','1');
linkOpt2h('sm','Small','font','1');
*/
h.push(endMenu);
//linkOpt2h('customize','','wrench', '1', 'Customize');
/*
if(opts.buttons.customize){
h.push(beginMenu('cust','wrench'));
link2h('customize','Customize this view','wrench');

@@ -143,3 +159,3 @@ h.push(menuDevider);

}
h.push('</ul>',EvoUI.html.clearer,'</div>');
h.push('</ul>',Evol.UI.html.clearer,'</div>');
return h.join('');

@@ -163,3 +179,4 @@ },

setView:function(viewName){
var $e=this.$el,
var opts=this.options,
$e=this.$el,
eid ='evolw-'+viewName,

@@ -170,11 +187,10 @@ $v=this.$('[data-vid="'+eid+'"]'),

var collec=this.model?this.model.collection:new opts.collectionClass();
if(viewName==='new'){
if(this._prevOne){
viewName=this._prevOne;
}else{
viewName='edit';
}
viewName=this._prevOne?this._prevOne:'edit';
this.setView(viewName);
this._isNew = true;
this.curView.clear();
this._isNew = true; // TODO model.isNew
this.model=new opts.modelClass();
this.model.collection=collec;
this.newItem();
this.curView.options.mode='new';

@@ -184,7 +200,19 @@ }else{

if($v.length){
// -- view already exists and was rendered
this.model=this.curView.model;
this.curView=this.viewsHash[viewName];
if(!this.isNew){
this.curView.setModel(this.model);
if(this.curView.setModel){
if(!this.curView.collection && m.collection){
this.curView.collection=this.model.collection;
}
this.curView.setModel(this.model);
}else{
this.curView.model = this.model;
}
if(!this.model){
this.curView.collection=collec;
}
}
this.$('[data-cid="views"] > li').removeClass('evo-sel') // TODO optimize
this.$('[data-id="views"] > li').removeClass('evo-sel') // TODO optimize
.filter('[data-id="'+viewName+'"]').addClass('evo-sel');

@@ -194,2 +222,3 @@ $v.show()

}else{
// -- create new instance of the view
$v=$('<div data-vid="evolw-'+viewName+'"></div>');

@@ -203,8 +232,10 @@ $e.children().not('.evo-toolbar,.evo-filters,.clearfix').hide();

model: this.model,
uiModel: this.options.uiModel
collection: this.collection,
uiModel: opts.uiModel,
style: opts.style,
titleSelector: opts.titleSelector
};
this.$('[data-id="new"]').show();
this.$('[data-cid="views"] > li').removeClass('evo-sel') // TODO optimize
this.$('[data-id="views"] > li').removeClass('evo-sel') // TODO optimize
.filter('[data-id="'+viewName+'"]').addClass('evo-sel');
switch(viewName){

@@ -228,2 +259,4 @@ // --- one ---

vw = new Evol.ViewExport(config);
$v.addClass('panel panel-info')
.slideDown();
break;

@@ -234,6 +267,11 @@ }

this.viewsHash[viewName]=vw;
if(this.curView._updateTitle){
this.curView._updateTitle(); // TODO fix: make public?
}else{
//TODO better way
$(this.options.titleSelector).html(this.curView.getTitle());
}
}
this.curView.options.mode=viewName;
}
this.setToolbar(viewName, this._isNew);
this.setMode(viewName);
return this;

@@ -246,6 +284,7 @@ },

this._toolbarButtons = {
ones: lis.filter('[data-cardi="1"]'),
ones: lis.filter('li[data-cardi="1"]'),
manys: lis.filter('li[data-cardi="n"]'),
prevNext: this.$('[data-id="prev"],[data-id="next"]'),
customize: this.$('a[data-id="customize"]').parent()
customize: this.$('a[data-id="customize"]').parent(),
views: this.$('[data-id="views"]')
};

@@ -256,6 +295,6 @@ }

setToolbar: function(mode){
function onemany(showOne, showMany){
EvoUI.setVisible(tbBs.ones, showOne);
EvoUI.setVisible(tbBs.manys, showMany);
setMode: function(mode){
function oneMany(showOne, showMany){
Evol.UI.setVisible(tbBs.ones, showOne);
Evol.UI.setVisible(tbBs.manys, showMany);
}

@@ -265,52 +304,47 @@

var tbBs=this.getToolbarButtons();
EvoUI.setVisible(tbBs.customize,mode!='json');
Evol.UI.setVisible(tbBs.customize,mode!='json');
tbBs.prevNext.hide();
Evol.UI.setVisible(tbBs.views, mode!=='export');
if(this._viewsIcon){
var cssOpen='glyphicon-eye-open',
cssClose='glyphicon-eye-close';
if(mode==='mini' || mode==='json'){
this._viewsIcon
.removeClass(cssOpen).addClass(cssClose);
}else{
this._viewsIcon
.removeClass(cssClose).addClass(cssOpen);
}
}
if(this._isNew || mode==='export'){
onemany(false, false);
oneMany(false, false);
if(this._isNew){
}
}else{
if(mode==='cards' || mode==='list' || mode==='charts'){
this._prevMany=mode;
onemany(false, true);
oneMany(false, true);
}else{
this._prevOne=mode;
onemany(true, false);
oneMany(true, false);
tbBs.prevNext.show();
}
}
if(mode==='cards'){
tbBs.manys.filter('[data-id="group"]').show();
}else{
tbBs.manys.filter('[data-id="group"]').hide();
}
Evol.UI.setVisible(tbBs.manys.filter('[data-id="group"]'), mode==='cards');
}
},
/*
showFilter: function(){
var that=this,
$ff;
if(this._$filters){
$ff=this._$filters.$el;
}else{
$ff=$(EvoUI.HTMLEmptyPanel('filters', 'evo-filters', 'primary'));
if(!this._filters){
var that=this,
$ff=$(Evol.UI.HTMLEmptyPanel('filters', 'evo-filters', 'info'));
this.$('.evo-toolbar').after($ff);
this._$filters = new Evol.ViewFilter({
this._filters = new Evol.ViewFilter({
el:$ff,
fields:EvoDico.fields(this.options.uiModel)
fields:Evol.Dico.getFields(this.options.uiModel)
}).render();
$ff.on('change.filter', function(evt){
//TEST
that.curView.model.collection.filter(function(model){
//var ok=true;
//filter
//for(var filter in filters){
return model.get('title')=='abc';
//}
//return ok;
});
that.curView.render();
$ff.on('change.filter', function(){
that.curView.setFilter(that._filters.val())
.render();
});

@@ -322,23 +356,6 @@ }

showGroup: function(){
var $fg;
if(this._$groups){
$fg=this._$groups;
}else{
$fg=$(EvoUI.HTMLEmptyPanel('groups', 'evo-groups', 'primary'));
this.$('.evo-toolbar').after($fg);
this._$groups=$fg;
this._$filters = new Evol.ViewFilter({
el:$fg,
fields:EvoDico.fields(this.options.uiModel)
}).render();
}
var visible=$fg.data('visible');
if(visible){
$fg.data('visible', false).slideUp();
}else{
$fg.hide().html('groups TEST TEST TEST groups...');
$fg.data('visible', true).slideDown();
}
this._group = true;
this.curView.showGroup();
return this;
},*/
},

@@ -379,5 +396,132 @@ setData: function(data){

saveItem: function(saveAndAdd){
var that=this,
vw=this.curView,
msg=vw.validate();
function fnSuccess(m){
if (saveAndAdd) {
that.newItem();
}else{
that.model=m;
that._isNew=false;
that.setMode('edit');
vw.setModel(m);
}
vw._updateTitle();
}
if(msg===''){
var entityName=Evol.UI.capFirstLetter(this.options.uiModel.entity);
if(this._isNew){
var collec=(this.model && this.model.collection)?this.model.collection:this.collection;
if(collec){
collec.create(this.getData(), {
success: function(m){
fnSuccess(m);
that.setMessage('Record saved.', Evol.i18n.getLabel('status.added',entityName,vw.getTitle()), 'success');
},
error:function(err){
alert('error');
}
});
this.options.mode='edit';
}else{
alert('Can\'t save record b/c no collection is specified.'); //TODO pretty
}
}else{
this.model.set(this.getData());
this.model.save('','',{
success: function(m){
fnSuccess(m);
that.setMessage('Record saved.', Evol.i18n.getLabel('status.updated',entityName,vw.getTitle()), 'success');
},
error:function(err){
alert('error');
}
});
}
}else{
this.setMessage('Invalid data.', msg, 'warning');
}
return this;
},
cancelItem: function(){
},
newItem: function(){
var vw=this.curView;
return vw.clear()
._updateTitle(Evol.i18n.getLabel('NewEntity', this.options.uiModel.entity, vw.getTitle()));
},
deleteItem: function(){
var entityName=this.options.uiModel.entity,
entityValue=this.curView.getTitle(),
delModel=this.curView.model;
// TODO good looking msgbox
if (delModel && confirm(Evol.i18n.getLabel('DeleteEntity', entityName, entityValue))) {
var that=this,
collec=this.collection,
delIdx=_.indexOf(collec.models, delModel),
newIdx=delIdx,
newModel=null;
if(collec.length>1){
if(delIdx===0){
newIdx=1;
}else if(delIdx<collec.length-1){
newIdx=delIdx+1;
}else{
newIdx=delIdx-1;
}
newModel = collec.at(newIdx);
}
if(newModel){
newModel.collection=collec;
}
delModel.destroy({
success:function(){
if(collec.length===0){
that.curView.clear();
}else{
this.model = newModel;
that.curView.setModel(newModel);
}
that.setMessage('Record Deleted.', Evol.i18n.getLabel('status.deleted', Evol.UI.capFirstLetter(entityName), entityValue), 'success');
},
error:function(err){
alert('error');
}
});
}
},
setMessage: function(title, content,style){
var $msg=this.$('[data-id="msg"]');
if($msg.length){
$msg.html('<strong>'+title+'</strong>'+content).show();
}else{
this.$el.prepend(Evol.UI.HTMLMsg(title, ' '+content, style));
}
return this;
},
clearMessage: function(){
this.$('[data-id="msg"]').remove();
return this;
},
action_view: function(evt, actionId){
if(actionId==='cancel'){
}else{
this.saveItem(actionId==='save-add');
}
},
click_toolbar: function(evt){
var that=this,
$e=$(evt.target);
var $e=$(evt.target);
if($e.tagName!=='A'){

@@ -391,18 +535,3 @@ $e=$e.closest('a');

case 'del':
// TODO good looking msgbox
if (confirm('Are you sure you want to delete this record?')) {
var delModel=this.curView.model,
newModel = delModel.collection.at(0);
this.model = newModel;
that.curView.setModel(newModel);
delModel.destroy({
success:function(){
that.curView.setMessage('Record Deleted', 'Record was removed.', 'success');
},
error:function(err){
alert('error');
}
});
}
this.deleteItem();
break;

@@ -422,6 +551,6 @@ case 'customize':

break;
case 'new-field':// ui-dico
case 'new-panel':// ui-dico
EvoDico.showDesigner('id', 'field', $e);
case 'new-field':
Evol.Dico.showDesigner('', 'field', $e);
break;
//case 'new-panel':// ui-dico
default:// 'edit', 'mini', 'list', 'cards', 'export', 'json', 'new'

@@ -433,3 +562,2 @@ if(toolId && toolId!==''){

}
evt.stopImmediatePropagation();
this.$el.trigger('toolbar.'+toolId);

@@ -439,9 +567,12 @@ },

click_navigate: function(evt,ui){
var m = this.model.collection.get(ui.id);
var m=this.collection.get(ui.id);
evt.stopImmediatePropagation();
this.model=m;
this.setView(this._prevOne || 'edit');
this.curView.model=m;
this.curView.setModel(m);
// todo: change model for all views / or model event
this.curView.render();
evt.stopImmediatePropagation();
},
click_download: function(evt){
alert('Sorry, no demo server yet...');
}

@@ -448,0 +579,0 @@

/*! ***************************************************************************
*
* evol-utility : ui-charts.js
* evolutility :: ui-charts.js
*
* https://github.com/evoluteur/evolutility
* Copyright (c) 2014, Olivier Giulieri

@@ -13,5 +14,5 @@ *

_HTML: function(title, urlPix){
_HTML: function(title, urlPix, style){
return [ //class="panel ', this.options.style, '
'<div class="evol-chart-holder panel panel-info"><label class="evol-chart-title">',title,
'<div class="evol-chart-holder panel ',style,'"><label class="evol-chart-title">',title,
'</label><img src="',urlPix,'"><br></div>'

@@ -21,4 +22,4 @@ ].join('');

Pie: function (label, data, labels){
var urlGoogleChart = [EvoUI.Charts.URL,'?chd=t:',
Pie: function (label, data, labels, style){
var urlGoogleChart = [this.URL,'?chd=t:',
data.join(','),

@@ -28,8 +29,8 @@ '&amp;chl=',

'&amp;cht=p&amp;chds=0,20&amp;chs=360x200'].join('');
return EvoUI.Charts._HTML(label, urlGoogleChart);
return this._HTML(label, urlGoogleChart, style || 'panel-default');
},
Bars: function (label, data, labels){
Bars: function (label, data, labels, style){
var maxCount = _.max(data),
urlGoogleChart = [EvoUI.Charts.URL,'?chbh=a&amp;chs=350x200&cht=bvg&chco=3a87ad,d9edf7&chds=0,',
urlGoogleChart = [this.URL,'?chbh=a&amp;chs=350x200&cht=bvg&chco=3a87ad,d9edf7&chds=0,',
maxCount,

@@ -41,3 +42,3 @@ '&amp;chd=t:',

].join('');
return EvoUI.Charts._HTML(label, urlGoogleChart);
return this._HTML(label, urlGoogleChart, style);
}

@@ -44,0 +45,0 @@

@@ -1,387 +0,2 @@

contacts_LOVs = {
categories: [
{id: '1', text: 'Work'},
{id: '2', text: 'Fun'},
{id: '3', text: 'Travel'},
{id: '4', text: 'Business'},
{id: '5', text: 'Cars'},
{id: '6', text: 'Sport'},
{id: '7', text: 'Misc.'}
],
states: [
{id: 'AL', text: 'Alabama'},
{id: 'AK', text: 'Alaska'},
{id: 'AZ', text: 'Arizona'},
{id: 'AR', text: 'Arkansas'},
{id: 'CA', text: 'California'},
{id: 'CO', text: 'Colorado'},
{id: 'CT', text: 'Connecticut'},
{id: 'DE', text: 'Delaware'},
{id: 'DC', text: 'District of Columbia'},
{id: 'FL', text: 'Florida'},
{id: 'GA', text: 'Georgia'},
{id: 'HI', text: 'Hawaii'},
{id: 'ID', text: 'Idaho'},
{id: 'IL', text: 'Illinois'},
{id: 'IN', text: 'Indiana'},
{id: 'IA', text: 'Iowa'},
{id: 'KS', text: 'Kansas'},
{id: 'KY', text: 'Kentucky'},
{id: 'LA', text: 'Louisiana'},
{id: 'ME', text: 'Maine'},
{id: 'MD', text: 'Maryland'},
{id: 'MA', text: 'Massachusetts'},
{id: 'MI', text: 'Michigan'},
{id: 'MN', text: 'Minnesota'},
{id: 'MS', text: 'Mississippi'},
{id: 'MO', text: 'Missouri'},
{id: 'MT', text: 'Montana'},
{id: 'NE', text: 'Nebraska'},
{id: 'NV', text: 'Nevada'},
{id: 'NH', text: 'New Hampshire'},
{id: 'NJ', text: 'New Jersey'},
{id: 'NM', text: 'New Mexico'},
{id: 'NY', text: 'New York'},
{id: 'NC', text: 'North Carolina'},
{id: 'ND', text: 'North Dakota'},
{id: 'OH', text: 'Ohio'},
{id: 'OK', text: 'Oklahoma'},
{id: 'OR', text: 'Oregon'},
{id: 'PA', text: 'Pennsylvania'},
{id: 'RI', text: 'Rhode Island'},
{id: 'SC', text: 'South Carolina'},
{id: 'SD', text: 'South Dakota'},
{id: 'TN', text: 'Tennessee'},
{id: 'TX', text: 'Texas'},
{id: 'UT', text: 'Utah'},
{id: 'VT', text: 'Vermont'},
{id: 'VA', text: 'Virginia'},
{id: 'WA', text: 'Washington'},
{id: 'WV', text: 'West Virginia'},
{id: 'WI', text: 'Wisconsin'},
{id: 'WY', text: 'Wyoming'}
],
countries: [
{text: 'Afghanistan', id: 'AF'},
{text: 'Åland Islands', id: 'AX'},
{text: 'Albania', id: 'AL'},
{text: 'Algeria', id: 'DZ'},
{text: 'American Samoa', id: 'AS'},
{text: 'Andorra', id: 'AD'},
{text: 'Angola', id: 'AO'},
{text: 'Anguilla', id: 'AI'},
{text: 'Antarctica', id: 'AQ'},
{text: 'Antigua and Barbuda', id: 'AG'},
{text: 'Argentina', id: 'AR'},
{text: 'Armenia', id: 'AM'},
{text: 'Aruba', id: 'AW'},
{text: 'Australia', id: 'AU'},
{text: 'Austria', id: 'AT'},
{text: 'Azerbaijan', id: 'AZ'},
{text: 'Bahamas', id: 'BS'},
{text: 'Bahrain', id: 'BH'},
{text: 'Bangladesh', id: 'BD'},
{text: 'Barbados', id: 'BB'},
{text: 'Belarus', id: 'BY'},
{text: 'Belgium', id: 'BE'},
{text: 'Belize', id: 'BZ'},
{text: 'Benin', id: 'BJ'},
{text: 'Bermuda', id: 'BM'},
{text: 'Bhutan', id: 'BT'},
{text: 'Bolivia', id: 'BO'},
{text: 'Bosnia and Herzegovina', id: 'BA'},
{text: 'Botswana', id: 'BW'},
{text: 'Bouvet Island', id: 'BV'},
{text: 'Brazil', id: 'BR'},
{text: 'British Indian Ocean Territory', id: 'IO'},
{text: 'Brunei Darussalam', id: 'BN'},
{text: 'Bulgaria', id: 'BG'},
{text: 'Burkina Faso', id: 'BF'},
{text: 'Burundi', id: 'BI'},
{text: 'Cambodia', id: 'KH'},
{text: 'Cameroon', id: 'CM'},
{text: 'Canada', id: 'CA'},
{text: 'Cape Verde', id: 'CV'},
{text: 'Cayman Islands', id: 'KY'},
{text: 'Central African Republic', id: 'CF'},
{text: 'Chad', id: 'TD'},
{text: 'Chile', id: 'CL'},
{text: 'China', id: 'CN'},
{text: 'Christmas Island', id: 'CX'},
{text: 'Cocos (Keeling) Islands', id: 'CC'},
{text: 'Colombia', id: 'CO'},
{text: 'Comoros', id: 'KM'},
{text: 'Congo', id: 'CG'},
{text: 'Congo, The Democratic Republic of the', id: 'CD'},
{text: 'Cook Islands', id: 'CK'},
{text: 'Costa Rica', id: 'CR'},
{text: 'Cote D\'Ivoire', id: 'CI'},
{text: 'Croatia', id: 'HR'},
{text: 'Cuba', id: 'CU'},
{text: 'Cyprus', id: 'CY'},
{text: 'Czech Republic', id: 'CZ'},
{text: 'Denmark', id: 'DK'},
{text: 'Djibouti', id: 'DJ'},
{text: 'Dominica', id: 'DM'},
{text: 'Dominican Republic', id: 'DO'},
{text: 'Ecuador', id: 'EC'},
{text: 'Egypt', id: 'EG'},
{text: 'El Salvador', id: 'SV'},
{text: 'Equatorial Guinea', id: 'GQ'},
{text: 'Eritrea', id: 'ER'},
{text: 'Estonia', id: 'EE'},
{text: 'Ethiopia', id: 'ET'},
{text: 'Falkland Islands (Malvinas)', id: 'FK'},
{text: 'Faroe Islands', id: 'FO'},
{text: 'Fiji', id: 'FJ'},
{text: 'Finland', id: 'FI'},
{text: 'France', id: 'FR'},
{text: 'French Guiana', id: 'GF'},
{text: 'French Polynesia', id: 'PF'},
{text: 'French Southern Territories', id: 'TF'},
{text: 'Gabon', id: 'GA'},
{text: 'Gambia', id: 'GM'},
{text: 'Georgia', id: 'GE'},
{text: 'Germany', id: 'DE'},
{text: 'Ghana', id: 'GH'},
{text: 'Gibraltar', id: 'GI'},
{text: 'Greece', id: 'GR'},
{text: 'Greenland', id: 'GL'},
{text: 'Grenada', id: 'GD'},
{text: 'Guadeloupe', id: 'GP'},
{text: 'Guam', id: 'GU'},
{text: 'Guatemala', id: 'GT'},
{text: 'Guernsey', id: 'GG'},
{text: 'Guinea', id: 'GN'},
{text: 'Guinea-Bissau', id: 'GW'},
{text: 'Guyana', id: 'GY'},
{text: 'Haiti', id: 'HT'},
{text: 'Heard Island and Mcdonald Islands', id: 'HM'},
{text: 'Holy See (Vatican City State)', id: 'VA'},
{text: 'Honduras', id: 'HN'},
{text: 'Hong Kong', id: 'HK'},
{text: 'Hungary', id: 'HU'},
{text: 'Iceland', id: 'IS'},
{text: 'India', id: 'IN'},
{text: 'Indonesia', id: 'ID'},
{text: 'Iran, Islamic Republic Of', id: 'IR'},
{text: 'Iraq', id: 'IQ'},
{text: 'Ireland', id: 'IE'},
{text: 'Isle of Man', id: 'IM'},
{text: 'Israel', id: 'IL'},
{text: 'Italy', id: 'IT'},
{text: 'Jamaica', id: 'JM'},
{text: 'Japan', id: 'JP'},
{text: 'Jersey', id: 'JE'},
{text: 'Jordan', id: 'JO'},
{text: 'Kazakhstan', id: 'KZ'},
{text: 'Kenya', id: 'KE'},
{text: 'Kiribati', id: 'KI'},
{text: 'Korea, Democratic People\'S Republic of', id: 'KP'},
{text: 'Korea, Republic of', id: 'KR'},
{text: 'Kuwait', id: 'KW'},
{text: 'Kyrgyzstan', id: 'KG'},
{text: 'Lao People\'S Democratic Republic', id: 'LA'},
{text: 'Latvia', id: 'LV'},
{text: 'Lebanon', id: 'LB'},
{text: 'Lesotho', id: 'LS'},
{text: 'Liberia', id: 'LR'},
{text: 'Libyan Arab Jamahiriya', id: 'LY'},
{text: 'Liechtenstein', id: 'LI'},
{text: 'Lithuania', id: 'LT'},
{text: 'Luxembourg', id: 'LU'},
{text: 'Macao', id: 'MO'},
{text: 'Macedonia, The Former Yugoslav Republic of', id: 'MK'},
{text: 'Madagascar', id: 'MG'},
{text: 'Malawi', id: 'MW'},
{text: 'Malaysia', id: 'MY'},
{text: 'Maldives', id: 'MV'},
{text: 'Mali', id: 'ML'},
{text: 'Malta', id: 'MT'},
{text: 'Marshall Islands', id: 'MH'},
{text: 'Martinique', id: 'MQ'},
{text: 'Mauritania', id: 'MR'},
{text: 'Mauritius', id: 'MU'},
{text: 'Mayotte', id: 'YT'},
{text: 'Mexico', id: 'MX'},
{text: 'Micronesia, Federated States of', id: 'FM'},
{text: 'Moldova, Republic of', id: 'MD'},
{text: 'Monaco', id: 'MC'},
{text: 'Mongolia', id: 'MN'},
{text: 'Montserrat', id: 'MS'},
{text: 'Morocco', id: 'MA'},
{text: 'Mozambique', id: 'MZ'},
{text: 'Myanmar', id: 'MM'},
{text: 'Namibia', id: 'NA'},
{text: 'Nauru', id: 'NR'},
{text: 'Nepal', id: 'NP'},
{text: 'Netherlands', id: 'NL'},
{text: 'Netherlands Antilles', id: 'AN'},
{text: 'New Caledonia', id: 'NC'},
{text: 'New Zealand', id: 'NZ'},
{text: 'Nicaragua', id: 'NI'},
{text: 'Niger', id: 'NE'},
{text: 'Nigeria', id: 'NG'},
{text: 'Niue', id: 'NU'},
{text: 'Norfolk Island', id: 'NF'},
{text: 'Northern Mariana Islands', id: 'MP'},
{text: 'Norway', id: 'NO'},
{text: 'Oman', id: 'OM'},
{text: 'Pakistan', id: 'PK'},
{text: 'Palau', id: 'PW'},
{text: 'Palestinian Territory, Occupied', id: 'PS'},
{text: 'Panama', id: 'PA'},
{text: 'Papua New Guinea', id: 'PG'},
{text: 'Paraguay', id: 'PY'},
{text: 'Peru', id: 'PE'},
{text: 'Philippines', id: 'PH'},
{text: 'Pitcairn', id: 'PN'},
{text: 'Poland', id: 'PL'},
{text: 'Portugal', id: 'PT'},
{text: 'Puerto Rico', id: 'PR'},
{text: 'Qatar', id: 'QA'},
{text: 'Reunion', id: 'RE'},
{text: 'Romania', id: 'RO'},
{text: 'Russian Federation', id: 'RU'},
{text: 'RWANDA', id: 'RW'},
{text: 'Saint Helena', id: 'SH'},
{text: 'Saint Kitts and Nevis', id: 'KN'},
{text: 'Saint Lucia', id: 'LC'},
{text: 'Saint Pierre and Miquelon', id: 'PM'},
{text: 'Saint Vincent and the Grenadines', id: 'VC'},
{text: 'Samoa', id: 'WS'},
{text: 'San Marino', id: 'SM'},
{text: 'Sao Tome and Principe', id: 'ST'},
{text: 'Saudi Arabia', id: 'SA'},
{text: 'Senegal', id: 'SN'},
{text: 'Serbia and Montenegro', id: 'CS'},
{text: 'Seychelles', id: 'SC'},
{text: 'Sierra Leone', id: 'SL'},
{text: 'Singapore', id: 'SG'},
{text: 'Slovakia', id: 'SK'},
{text: 'Slovenia', id: 'SI'},
{text: 'Solomon Islands', id: 'SB'},
{text: 'Somalia', id: 'SO'},
{text: 'South Africa', id: 'ZA'},
{text: 'South Georgia and the South Sandwich Islands', id: 'GS'},
{text: 'Spain', id: 'ES'},
{text: 'Sri Lanka', id: 'LK'},
{text: 'Sudan', id: 'SD'},
{text: 'Suriname', id: 'SR'},
{text: 'Svalbard and Jan Mayen', id: 'SJ'},
{text: 'Swaziland', id: 'SZ'},
{text: 'Sweden', id: 'SE'},
{text: 'Switzerland', id: 'CH'},
{text: 'Syrian Arab Republic', id: 'SY'},
{text: 'Taiwan, Province of China', id: 'TW'},
{text: 'Tajikistan', id: 'TJ'},
{text: 'Tanzania, United Republic of', id: 'TZ'},
{text: 'Thailand', id: 'TH'},
{text: 'Timor-Leste', id: 'TL'},
{text: 'Togo', id: 'TG'},
{text: 'Tokelau', id: 'TK'},
{text: 'Tonga', id: 'TO'},
{text: 'Trinidad and Tobago', id: 'TT'},
{text: 'Tunisia', id: 'TN'},
{text: 'Turkey', id: 'TR'},
{text: 'Turkmenistan', id: 'TM'},
{text: 'Turks and Caicos Islands', id: 'TC'},
{text: 'Tuvalu', id: 'TV'},
{text: 'Uganda', id: 'UG'},
{text: 'Ukraine', id: 'UA'},
{text: 'United Arab Emirates', id: 'AE'},
{text: 'United Kingdom', id: 'GB'},
{text: 'United States', id: 'US'},
{text: 'United States Minor Outlying Islands', id: 'UM'},
{text: 'Uruguay', id: 'UY'},
{text: 'Uzbekistan', id: 'UZ'},
{text: 'Vanuatu', id: 'VU'},
{text: 'Venezuela', id: 'VE'},
{text: 'Viet Nam', id: 'VN'},
{text: 'Virgin Islands, British', id: 'VG'},
{text: 'Virgin Islands, U.S.', id: 'VI'},
{text: 'Wallis and Futuna', id: 'WF'},
{text: 'Western Sahara', id: 'EH'},
{text: 'Yemen', id: 'YE'},
{text: 'Zambia', id: 'ZM'},
{text: 'Zimbabwe', id: 'ZW'}
]
};
var contacts_ui = {
id: 1,
label: 'Address book',
icon: 'contact.gif',
entity: 'contact', entities: 'contacts',
elements: [
{ type: 'panel', label: 'Identity', width: 62,
elements: [
{ type: 'text', id: 'lastname', label: 'Lastname', maxlength: 50,
required: true, cssclass: 'FieldMain',
width: '62', viewmany: true},
{ type: 'text', id: 'firstname', label: 'Firstname', maxlength: 50,
required: true, cssclass: 'FieldMain',
width: 38, viewmany: true},
{ type: 'text', id: 'jobtitle', label: 'Title', maxlength: 50,
width: 62},
{ type: 'text', id: 'company', label: 'Company', maxlength: 50,
width: 38, viewmany: true},
{ type: 'email', id: 'email', label: 'email', maxlength: 255,
width: 100, viewmany: true}
]
},
{type: 'panel', label: 'Contact Info', width: '38',
elements: [
{type: 'text', id: 'phone', label: 'Work Phone', maxlength: 20,
width: '50'},
{type: 'text', id: 'phonehome', label: 'Home Phone', maxlength: 20,
width: '50'},
{type: 'text', id: 'phonecell', label: 'Cell.', maxlength: 20,
width: '50', mini:'1'},
{type: 'text', id: 'fax', label: 'Fax', maxlength: 20,
width: '50'},
{type: 'url', id: 'web', label: 'web', maxlength: 255,
width: '100'}
]
},
{type: 'panel', label: 'Address', width: 62,
elements: [
{type: 'text', id: 'address1', label: 'Address', maxlength: 150,
width: 100},
{type: 'text', id: 'address2', label: '', labellist: 'Address 2', maxlength: '150',
width: 100},
{type: 'text', id: 'city', label: 'City', maxlength: 100,
width: 62},
{type: 'lov', id: 'state', label: 'State', maxlength: 3,
width: 15,
list: contacts_LOVs.states
},
{type: 'text', id: 'zip', label: 'Zip', maxlength: 12,
width: 23},
{type: 'lov', id: 'country', label: 'Country', maxlength: 60, width: 100,
list: contacts_LOVs.countries
}
]
},
{type: 'panel', label: 'Misc.', width: '38',
elements: [
{type: 'lov', id: 'category', label: 'Category', width: 100,
viewmany: true,
list: contacts_LOVs.categories
},
{type: 'text', id: 'custom1', label: 'Custom 1', maxlength: 250,
width: 100},
{type: 'text', id: 'custom2', label: 'Custom 2', maxlength: 250,
width: 100},
{type: 'text', id: 'custom3', label: 'Custom 3', maxlength: 250,
width: 100}
]
}
]
};
var contacts_data = [

@@ -388,0 +3,0 @@ {id: '690', lastname: 'Smallwood', firstname: 'Vincent', jobtitle: 'Director', company: 'EasyDoesIt',

@@ -319,3 +319,5 @@ var contacts_LOVs = {

entity: 'contact', entities: 'contacts',
leadfield: function(model){
return model.get('firstname')+' '+model.get('lastname');
},
elements: [

@@ -322,0 +324,0 @@ {type: 'panel', label: 'Identity', width: 62,

var todo_data = function(){
var today=new Date();
function date2string(nbDays){
var d=new Date();
d.setDate(today.getDate()+nbDays);
return d;
}
return [
{id: '322', title: 'Test', duedate: date2string(10), priority: '2', category: 'others', complete: false, notes: ''},
{id: '304', title: 'Another task', duedate: date2string(15), priority: '3', category: 'work', complete: false, notes: 'bla bla'},
{id: '335', title: 'Testing App', duedate: date2string(30), priority: '3', category: 'work', complete: false, notes: 'test'},
{id: '343', title: 'Demo Task', duedate: date2string(20), priority: '1', category: 'work', complete: false, notes: 'Check this out'},
{id: '344', title: 'Test done', duedate: date2string(-2), priority: '5', category: 'misc', complete: true, notes: 'notes for my test todo task\nthis is pretty nice with different fonts.\n\n,,'},
{id: '345', title: 'Teste do meu TODO', duedate: date2string(61), priority: '2', category: 'misc', complete: false, notes: 'teste'},
{id: '346', title: 'Car wash', duedate: date2string(14), priority: '4', category: 'work', complete: false, notes: ''},
{id: '347', title: 'Watch Inception', duedate: date2string(30), priority: '5', category: 'fun', complete: false, notes: ''},
{id: '348', title: 'Test TODO', duedate: date2string(2), priority: '1', category: 'work', complete: true, notes: 'Test TODO '}
];
};
var todo_data = [
{id: '322', title: 'Test', duedate: '2014-02-01', priority: '2', category: 'others', complete: false, notes: ''},
{id: '304', title: 'Another task', duedate: '2014-01-25', priority: '3', category: 'work', complete: false, notes: 'bla bla'},
{id: '335', title: 'Testing App', duedate: '2014-02-11', priority: '3', category: 'work', complete: false, notes: 'test'},
{id: '343', title: 'Demo Task', duedate: '2014-02-12', priority: '1', category: 'work', complete: false, notes: 'Check this out'},
{id: '344', title: 'Test done', duedate: '2014-04-15', priority: '5', category: 'misc', complete: true, notes: 'notes for my test todo task\nthis is pretty nice with different fonts.\n\n,,'},
{id: '345', title: 'Teste do meu TODO', duedate: '2014-02-14', priority: '2', category: 'misc', complete: false, notes: 'teste'},
{id: '346', title: 'Car wash', duedate: '2014-02-01', priority: '4', category: 'work', complete: false, notes: ''},
{id: '347', title: 'Watch Inception', duedate: '2014-01-10', priority: '5', category: 'fun', complete: false, notes: ''},
{id: '348', title: 'Test TODO', duedate: '2014-01-01', priority: '1', category: 'work', complete: true, notes: 'Test TODO '}
];

@@ -8,2 +8,3 @@

icon: 'todo.gif',
leadfield:'title',
elements: [

@@ -20,6 +21,6 @@ {

{
id: 'duedate', type: 'date', label: 'Due Date', width: 40, viewmany: true
id: 'duedate', type: 'date', label: 'Due Date', width: 62, viewmany: true
},
{
id: 'category', type: 'lov', label: 'Category', width: 60, viewmany: true,
id: 'category', type: 'lov', label: 'Category', width: 38, viewmany: true,
list: [

@@ -26,0 +27,0 @@ {id: 'home', text: 'Home'},

var winecellar_lovs = {
bottleSize: [

@@ -94,9 +95,19 @@ {id:750, text:'750 ml'},

type: [
{id:'red',text:'Red', icon:'winered.gif'},
{id:'white',text:'White', icon:'winewhite.gif'},
{id:'sweet',text:'Sweet', icon:'winesweet.gif'},
{id:'spark',text:'Sparkling', icon:'winespark.gif'},
{id:'rose',text:'Rose', icon:'winerose.gif'}
{id:'red',text:'Red', icon:'pix/wine/winered.gif'},
{id:'white',text:'White', icon:'pix/wine/winewhite.gif'},
{id:'sweet',text:'Sweet', icon:'pix/wine/winesweet.gif'},
{id:'spark',text:'Sparkling', icon:'pix/wine/winespark.gif'},
{id:'rose',text:'Rose', icon:'pix/wine/winerose.gif'}
],
score: [
//{id:'', text:'NR', icon:'s00.gif'},
{id:0, text:'', icon:'s0.gif'},
{id:1, text:'*', icon:'s1.gif'},
{id:2, text:'**', icon:'s2.gif'},
{id:3, text:'***', icon:'s3.gif'},
{id:4, text:'****', icon:'s4.gif'},
{id:5, text:'*****', icon:'s5.gif'}
],
country: [

@@ -122,2 +133,3 @@ {id: 'AR', text: 'Argentina'},

]
};

@@ -129,2 +141,6 @@

label: 'Wine Cellar',
icon: 'wine.gif',
leadfield: function(model){
return model.get('name')+' '+model.get('vintage');
},
elements: [

@@ -150,7 +166,7 @@ {

required: true,
maxlength: 100,
maxlength: 4,
viewmany: true,
width: 38,
min: 1900,
max: 2012,
max: 2020,
help: 'Year the wine was produced.'

@@ -178,3 +194,3 @@ }

width: '62',
help: 'The establishment where wine is made.'
help: 'The establishment where this wine is made.'
},

@@ -270,16 +286,12 @@ {

id:'price',
type: 'decimal',
type: 'money',
label: 'Price',
maxlength: 10,
viewmany: true,
width: '30',
format: '$ 0.00'
width: '30'
},
{
id:'value',
type: 'decimal',
type: 'money',
label: 'Value',
maxlength: 10,
width: 30,
format: '$ 0.00'
width: 30
},

@@ -386,11 +398,3 @@ {

labellist: 'Score',
list: [
//{id:'', text:'NR', icon:'s00.gif'},
{id:0, text:'', icon:'s0.gif'},
{id:1, text:'*', icon:'s1.gif'},
{id:2, text:'**', icon:'s2.gif'},
{id:3, text:'***', icon:'s3.gif'},
{id:4, text:'****', icon:'s4.gif'},
{id:5, text:'*****', icon:'s5.gif'}
],
list: winecellar_lovs.score,
maxlength: 100,

@@ -423,12 +427,13 @@ viewmany: true,

elements: [
{ type: 'panel-list',
{
type: 'panel-list',
id:'pnl-Degustations',
attr:'degustation',
label: 'Degustations',
width: 100,
elements: [
{id: 'Robe', type: 'text', label: 'Robe', maxlength: 100, viewmany: '1'},
{id: 'ddate', type: 'date', label: 'Date', maxlength: 20, viewmany: '1'},
{id: 'Nose', type: 'text', label: 'Nose', maxlength: 100, viewmany: '1'},
{id: 'Taste', type: 'text', label: 'Taste', maxlength: 100, viewmany: '1'},
{id: 'robe', type: 'text', label: 'Robe', maxlength: 100, viewmany: '1'},
{id: 'nose', type: 'text', label: 'Nose', maxlength: 100, viewmany: '1'},
{id: 'taste', type: 'text', label: 'Taste', maxlength: 100, viewmany: '1'},
{id: 'notes', type: 'textmultiline', label: 'Note', maxlength: 300, viewmany: '1', width: 100, height: '4'}

@@ -449,2 +454,3 @@ ]

{
id: 'comments',
type: 'textmultiline',

@@ -463,59 +469,1 @@ label: 'Comments',

};
/*
winetasting = {
entity: 'wine tasting',
entities: 'wine tastings', elements: [
{
type: 'panel',
label: 'Wine Tasting',
width: 50,
elements: [
{
type: 'lov',
label: 'Wine',
viewmany: '1',
width: '62',
required: '1',
link: 'demo_winecellar.aspx?ID=@itemid'
},
{
type: 'date',
label: 'Date',
maxlength: '20',
viewmany: '1',
width: '38'
},
{
type: 'text',
label: 'Robe',
maxlength: '100',
viewmany: '1',
width: '30'
},
{
type: 'text',
label: 'Nose',
maxlength: '100',
viewmany: '1',
width: '32'
},
{
type: 'text',
label: 'Taste',
maxlength: '100',
viewmany: '1',
width: '38'
},
{
type: 'textmultiline',
label: 'Note',
maxlength: '300',
width: 100,
height: '4'
}
]
}
]
};
*/
/*! ***************************************************************************
*
* evol-utility : ui.js
* evolutility :: ui.js
*
* https://github.com/evoluteur/evolutility
* Copyright (c) 2014, Olivier Giulieri

@@ -10,8 +11,16 @@ *

var Evol = Evol || {};
/*
Evol.CSS = {
field: 'evo-field form-control ',
fieldLabel: 'evol-field-label',
panel: '',
tab: '',
tabHeader: ''
};*/
Evol.UI = {
version: '0.0.1',
version: '0.0.2',
// html fragments
// --- static html fragments ---
html: {

@@ -21,23 +30,8 @@ trTableEnd: '</tr></table>',

clearer: '<div class="clearfix"></div>',
emptyOption: '<option value=""></option>'
emptyOption: '<option value=""></option>',
glyphicon: 'glyphicon glyphicon-',
required: '<span class="evol-required">*</span>'
},
icons: {
customize: function (id, type) {
return ['<i class="glyphicon glyphicon-wrench" data-id="', id, '" data-type="', type, '"></i>'].join('');
}
},
styles:{
'success':'success',
'info':'info',
'warning':'warning',
'danger':'danger'
},
// reusable html
html_more: function (label) {
return ['<a href="javascript:void(0)" class="evol-more">', label, '</a>'].join('');
},
// --- field labels ---
fieldLabel: function (fID, fLbl) {

@@ -50,132 +44,183 @@ return ['<div class="evol-field-label"><label for="', fID, '">', fLbl, '</label></div>'].join('');

link: function (fID, label, url) {
return ['<a class="Field" href="', url, '" id="', fID, '">', label, '</a>'].join('');
},
linkEmail: function (fID, label, email) {
return EvoUI.link(fID, label, email ? 'mailto:' + email : '');
},
inputText: function (fID, fV, fd) {
var h = ['<input class="form-control" type="text" id="', fID, '" value="', fV];
if (fd) {
_.each(['min', 'max', 'maxlength', 'max-width', 'min-width', 'placeholder'], function (item) {
if (fd[item] !== 'undefined') {
h.push('" ', item, '="', fd[item]);
// --- input fields ---
input: {
text: function (fID, fV, fd, css, size) {
var fCss= 'evo-field form-control ' + (css || '') + Evol.UI.getSizeCSS(size),
h = ['<input type="text" id="',fID,'" value="', fV];
if(fd) {
// properties mapping to html attributes
_.each(['id', 'min', 'max', 'maxlength', 'placeholder'], function (item) { // 'max-width', 'min-width',
if (fd[item] !== undefined) {
h.push('" ', item, '="', fd[item]);
}
});
//other fields attributes
if(fd.readonly){
var fi = fd.readonly;
if (fi || fi == '1') {
h.push('" ', item, '="', item);
}
}
});
_.each(['readonly'], function (item) {
var fi = fd[item];
if (fi || fi == '1') {
h.push('" ', item, '="', item);
if(fCss && fCss!==''){
h.push('" class="', fCss);
}
}
h.push('">');
return h.join('');
},
textInt: function (fID, fV, min, max) {
var h=['<input class="evo-field form-control" type="number" id="', fID,
'" value="', fV];
if(min!==undefined){
h.push('" min="', min);
}
if(max!==undefined){
h.push('" max="', max);
}
h.push('" maxlength="12">');
return h.join('');
},
textM: function (fID, fV, ml, h) {
return [
'<textarea name="', fID, '" id="', fID, '" class="evo-field form-control"" rows="', h,
(ml > 0) ? '" onKeyUp="Evol.UI.Validation.checkMaxLen(this,' + ml + ')' : '',
'">', fV, '</textarea>'
].join('');
},
textMJSON: function (fID, fVobj, h) {
return ['<textarea rows="',h,'" class="evol-json">', _.escape(JSON.stringify(fVobj, null, '\t')), '</textarea>'].join('');
},
myType: function (type, fId, fVal) {
return [
'<input type="', type, '" id="', fId, '" value="', fVal,
'" class="evo-field form-control" size="15">'
].join('');
},
date: function (fID, fV) {
return this.myType('date', fID, fV);
//+'&nbsp;<a href="javascript:ShowDatePicker(\'', fID, '\');" class="ico Calendar"></a></nobr>'
},
dateTime: function (fID, fV) {
return this.myType('datetime-local', fID, fV);
},
time: function (fID, fV) {
return this.myType('time', fID, fV);
},
typeFlag: function(id){
return '<span class="input-group-addon">'+id+'</span>';
},
color: function (fId, fVal) {
return [
'<input type="color" id="', fId, '" value="', fVal, '" size="15">'
].join('');
},
checkbox: function (fID, fV) {
var fh = ['<input type="checkbox" id="', fID, '"'];
if (fV !== null && fV !== '' && fV !== '0') {
fh.push(' checked="checked"');
}
fh.push(' value="1">');
return fh.join('');
},
checkboxLOV:function(fLOV){
var h=[];
for(var i in fLOV){
var lv=fLOV[i];
h.push('<input type="checkbox" id="',lv.id,'" value="',lv.id,'"/>',
'<label for="',lv.id,'">',lv.text,'</label> ');
}
return h.join('');
},
radio: function (fN, fV, fLbl, sel, fID) {
return ['<label for="', fID, '"><input id="', fID, '" name="', fN, '" type="radio" value="', fV,
(sel) ? '" checked="checked' : '',
'">', fLbl, '</label>&nbsp;'
].join('');
},
lov: function (fID, fV, fVLabel, fLOV) {
var h = ['<select class="evo-field form-control" id="', fID, '"><option value="', fV, '" selected>', fVLabel, '</option>'];
_.each(fLOV, function (f) {
h.push(this.option(f.id, f.text));
});
h.push('</select>');
return h.join('');
},
img: function (fID, fV) {
return ['<img id=""', fID, '" src="', fV, '"/>'].join('');
},
hidden: function (fID, fV) {
return ['<input type="hidden" name="', fID, '" id="', fID, '" value="', fV, '"/>'].join('');
},
hiddens: function (h, list) {
_.each(function (){
h.push('<input type="hidden" name="', fID, '" id="', fID, '" value="', fV, '"/>');
});
},
selectBegin: function (fID, css, emptyOption) {
var h=['<select id="', fID, '" class="form-control ',css,'">'];
if(emptyOption){
h.push(Evol.UI.html.emptyOption);
}
return h.join('');
},
select:function (fID, css, emptyOption, list) {
return [
this.selectBegin(fID, css, emptyOption),
this.options(list),'</select>'
].join('');
},
option: function (fID, fV) {
return ['<option value="', fID, '">', fV, '</option>'].join('');
},
options: function (fields) {
var fnOpt = Evol.UI.input.option,
opts=[];
_.each(fields,function(f){
opts.push(fnOpt(f.id, f.text));
});
return opts.join('');
},
button: function (id, label, css) {
return '<button type="button" data-id="' + id + '" class="btn' + (css ? ' ' + css : '') + '">' + label + '</button>';
}
h.push('" class="Field">');
return h.join('');
/*
toggle: function (items) {
var h=['<div class="btn-group" data-toggle="buttons">'];
_.each(items, function(item){
h.push('<label class="btn btn-info"><input type="radio" name="options" id="',item.id,'">',item.text,'</label>');
});
h.push('</div>');
return h.join('');
},*/
},
inputTextInt: function (fID, fV) {
return ['<input class="form-control" type="number" id="', fID, '" value="', fV,
'" class="Field" maxlength="12">'].join('');
// --- links ---
link: function (fID, label, url) {
return ['<a class="evo-field" href="', url, '" id="', fID, '">', label, '</a>'].join('');
},
inputTextM: function (fID, fV, ml, h) {
return [
'<textarea name="', fID, '" id="', fID, '" class="Field form-control"" rows="', h,
(ml > 0) ? '" onKeyUp="EvoVal.checkMaxLen(this,' + ml + ')' : '',
'">', fV, '</textarea>'
].join('');
linkEmail: function (fID, label, email) {
return Evol.UI.link(fID, label, email ? 'mailto:' + email : '');
},
inputTextMJSON: function (fID, fVobj, h) {
return ['<textarea rows="',h,'" class="evol-json">', _.escape(JSON.stringify(fVobj, null, '\t')), '</textarea>'].join('');
//html_more: function (label) {
// return ['<a href="javascript:void(0)" class="evol-more">', label, '</a>'].join('');
//},
// --- icons ---
icon: function (icon, cls) {
return ['<i class="', cls? cls+' ':'', Evol.UI.html.glyphicon, icon, '"></i>'].join('');
},
inputAny: function (type, fId, fVal) {
return [
'<input type="', type, '" id="', fId, '" value="', fVal,
'" class="Field form-control" size="15">'
].join('');
},
inputDate: function (fID, fV) {
return EvoUI.inputAny('date', fID, fV);
//+'&nbsp;<a href="javascript:ShowDatePicker(\'', fID, '\');" class="ico Calendar"></a></nobr>'
},
inputDateTime: function (fID, fV) {
return EvoUI.inputAny('datetime-local', fID, fV);
},
inputTime: function (fID, fV) {
return EvoUI.inputAny('time', fID, fV);
},
inputColor: function (fId, fVal) {
return [
'<input type="color" id="', fId, '" value="', fVal, '" size="15">'
].join('');
},
inputCheckbox: function (fID, fV) {
var fh = ['<input type="checkbox" id="', fID, '"'];
if (fV !== null && fV !== '' && fV !== '0') {
fh.push(' checked="checked"');
}
fh.push(' value="1">');
return fh.join('');
},
inputCheckboxLOV:function(fLOV){
var h=[];
for(var i in fLOV){
var lv=fLOV[i];
h.push('<input type="checkbox" id="',lv.id,'" value="',lv.id,'"/>',
'<label for="',lv.id,'">',lv.text,'</label> ');
}
return h.join('');
},
inputRadio: function (fN, fV, fLbl, sel, fID) {
return ['<label for="', fID, '"><input id="', fID, '" name="', fN, '" type="radio" value="', fV,
(sel) ? '" checked="checked' : '',
'">', fLbl, '</label>&nbsp;'
].join('');
},
inputLOV: function (fID, fV, fVLabel, fLOV) {
var h = ['<select class="form-control Field" id="', fID, '"><option value="', fV, '" selected>', fVLabel, '</option>'];
_.each(fLOV, function (f) {
h.push(EvoUI.inputOption(f.id, f.text));
});
h.push('</select>');
return h.join('');
},
inputHidden: function (fID, fV) {
return ['<input type="hidden" name="', fID, '" id="', fID, '" value="', fV, '"/>'].join('');
},
inputSelectBegin: function (fID, css, emptyOption) {
var h=['<select id="', fID, '" class="form-control ',css,'">'];
if(emptyOption){
h.push(Evol.UI.html.emptyOption);
}
return h.join('');
},
inputOption: function (fID, fV) {
return ['<option value="', fID, '">', fV, '</option>'].join('');
},
inputOptions: function (fields) {
var opts=[];
_.each(fields,function(f){
opts.push(EvoUI.inputOption(f.id, f.text));
});
return opts.join('');
},
inputButton: function (id, label, cls) {
return '<button type="button" id="' + id + '" class="btn' + (cls ? ' ' + cls : '') + '">' + label + '</button>';
},
inputToggle: function (items) {
var h=['<div class="btn-group" data-toggle="buttons">'];
_.each(items, function(item){
h.push('<label class="btn btn-info"><input type="radio" name="options" id="',item.id,'">',item.text,'</label>');
});
h.push('</div>');
return h.join('');
iconCustomize: function (id, type) {
return Evol.UI.iconId(id, type, 'wrench');
},
icon: function (icon, cls) {
return ['<span class="', cls? cls+' ':'', 'glyphicon glyphicon-', icon, '"></span>'].join('');
iconId: function (id, type, icon) {
return ['<i class="',Evol.UI.html.glyphicon, icon, '" data-id="', id, '" data-type="', type, '"></i>'].join('');
},
// --- panels ---
HTMLPanelLabel: function (PanelLabel) {
return [
'<div class="panel-heading">', EvoUI.icon('chevron-up', 'evol-title-toggle'),
'<div class="panel-heading">', Evol.UI.icon('chevron-up', 'evol-title-toggle'),
'<h3 class="panel-title">', PanelLabel, '</h3></div>'

@@ -189,2 +234,3 @@ ].join('');

// --- status ---
HTMLMsg: function (title, content, style, dismissable) {

@@ -200,9 +246,50 @@ return [

formatDate: function(d){
return (d.getMonth()+1) + "/" + (d.getDate()+1) + "/" + d.getFullYear();
// --- date formats ---
formatDate: function(d){ // TODO use date not string as param
return d;
//return d.toLocaleDateString();
//return (d.getMonth()+1) + "/" + d.getDate() + "/" + d.getFullYear();
},
formatTime: function(d){
return (d.getHours()) + ":" + (d.getMinutes());
formatTime: function(d){ // TODO use date not string as param
return d;
//return d.toLocaleTimeString();
//return (d.getHours()) + ":" + (d.getMinutes());
},
formatDateTime: function(d){ // TODO use date not string as param
if(d!==undefined && d!==''){
var dateParts= d.split('-');
if(dateParts.length>1){
return dateParts[1]+'/'+dateParts[2]+'/'+dateParts[0];
}
}
return '';
/*
//var myDate = new Date(v);
//if(_.isDate(myDate)){
var dv='';
//return myDate.toLocaleDateString("en-US");
if(f.type!=fTypes.time){
dv+=this.formatDate(myDate);
if(f.type==fTypes.datetime){
dv+=' ';
}
}
if(f.type!=fTypes.date){
dv+=this.formatTime(myDate);
}
return dv;
//}*/
},
// --- Misc. ---
getSizeCSS: function(size){
switch(size){
case 'S':
return ' input-sm';
case 'L':
return ' input-lg';
}
return '';
},
/*
// get w/ automatic create if not in DOM

@@ -217,3 +304,3 @@ getOrCreate: function (fID,$holder) {

return e;
},
},*/

@@ -220,0 +307,0 @@ // insert a dataSet into a Backbone collection

{
"name": "evolutility",
"version": "0.0.1",
"copyright": "(c) 2013 Olivier Giulieri",
"version": "0.0.2",
"copyright": "(c) 2014 Olivier Giulieri",
"target": "dist",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-concat": "~0.2.0",
"grunt-contrib-uglify": "~0.2.1",
"grunt-contrib-less": "~0.5.2",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-jshint": "~0.4.3",
"grunt-bower-task": "~0.3.1"
},
"dependencies": {
"jquery": "~2.0.3",
"backbone": "~1.1.0",
"underscore": "~1.5.2",
"underscore.string": "~2.3.3",
"bootstrap": "~3.0.3"
}
"grunt": "0.4.1",
"grunt-contrib-concat": "0.3.0",
"grunt-contrib-uglify": "0.2.6",
"grunt-contrib-less": "0.8.1",
"grunt-contrib-copy": "0.4.1",
"grunt-contrib-jshint": "0.4.3",
"grunt-bower-task": "0.3.1"
}
}

@@ -1,23 +0,21 @@

# evolutility
# evolutility.js
evolutility is a work in progress. Eventually it will be a generic UI to build applications who can change form, volume, and structure like living organisms.
evolutility.js is a work in progress. Eventually it will be a generic UI to build applications who can change form, volume, and structure like living organisms.
Evolutility (Bio.): The faculty possessed by all substances capable of self-nourishment of manifesting the nutritive acts by change of form, of volume, or of structure.
The idea is to build a set of generic Backbone views to perform all CRUD (Create, Read, Update and Delete) operations on records of any data structure.
For each object the whole set of views is defined in a single UI-model containing the description of UI (layout, fields and behaviors).
The idea is to build a set of generic Backbone views to perform all CRUD (Create, Read, Update and Delete) on records of any data structure.
These generic Backbone views will all be defined in a single UI-model containing the description of UI (layout, fields and behaviors).
## The Plan
* Update [Evolutility metamodel] (http://www.codeproject.com/Articles/28636/Minimalist-Meta-Model-for-CRUD-Applications) (model of the UI models)
* Code the generic UI views based on the metamodel
* Add a toolbar and a controller for all these views
* Make demo apps
* Make [an app to make apps] (http://www.codeproject.com/Articles/28810/Wizard-and-CRUD-Applications-to-Build-other-CRUD-A)
1. Update [Evolutility metamodel] (http://www.codeproject.com/Articles/28636/Minimalist-Meta-Model-for-CRUD-Applications) (model of the UI models)
2. Code the generic UI views based on the metamodel
3. Add a toolbar and a controller for all these views
4. Make demo apps
5. Make [an app to make apps] (http://www.codeproject.com/Articles/28810/Wizard-and-CRUD-Applications-to-Build-other-CRUD-A)
## 1 - Meta-model
## 1 - UI-model
To define applications we will need some kind of declarative language.
It will be based on [Minimalist Meta-Model for CRUD Applications](http://www.codeproject.com/Articles/28636/Minimalist-Meta-Model-for-CRUD-Applications)
To define UI-models evolutility uses some kind of UI language.
It is not fully defined yet but the syntax of UI-models will be based on [Minimalist Meta-Model for CRUD Applications](http://www.codeproject.com/Articles/28636/Minimalist-Meta-Model-for-CRUD-Applications)
using JSON rather than XML this time.

@@ -28,28 +26,31 @@

Sample UI Models:
[To Do list](http://github.com/evoluteur/evolutility/blob/master/js/ui-models/todo.js),
[AddressBook](http://github.com/evoluteur/evolutility/blob/master/js/ui-models/contacts.js),
[Wine Cellar](http://github.com/evoluteur/evolutility/blob/master/js/ui-models/winecellar.js).
[To Do list](http://github.com/evoluteur/evolutility/blob/master/js/ui-models/apps/todo.js),
[AddressBook](http://github.com/evoluteur/evolutility/blob/master/js/ui-models/apps/contacts.js),
[Wine Cellar](http://github.com/evoluteur/evolutility/blob/master/js/ui-models/apps/winecellar.js).
## 2 - Views
evolutility views have a Backbone model (to define the data) and also a UI model (to define the UI for interacting with the data).
evolutility's views have a Backbone model (to define the data) and also a UI model (to define the UI for interacting with the data).
Views for one record (one): new, edit, mini, json...
Views for a collection (many): list, cards, charts...
Evolutility will have 3 types of view
* Views for one record (one): new, edit, mini, json...
* Views for a collection (many): list, cards, charts...
* Views for actions on one record or a collection: export, filter, dashboards, Mass Update...
Extra views: Dashboards, Selections, Export, Mass Update, Search.
Based on its UI model, this set of views can be an address book, a to do list, or anything you want.
## 3 - Toolbar/Controller
We will also need a toolbar and a controller (for now the same js class).
## 4 - Demo apps
Soon. For now, please download the code and try it on your computer.
## 5 - The app to make other apps
A set of ui-models and models for the ui-model itself: fields, panels, tabs.
(...and some code in the view themselves to make it possible)
## Techno
## Techno and Libraries
Javascript, HTML5, CSS3,

@@ -63,3 +64,3 @@ [Backbone] (http://backbonejs.org),

evolutility.js is a re-write of [Evolutility] (http://www.evolutility.org) generic UI for CRUD.
evolutility.js is a re-write of [Evolutility] (http://www.evolutility.org) generic CRUD UI for ASP.net.

@@ -71,3 +72,3 @@

evolutility is released under the GNU Affero General Public License version 3 [GNU AGPLv3](http://www.gnu.org/licenses/agpl-3.0.html).
evolutility.js is released under the GNU Affero General Public License version 3 [GNU AGPLv3](http://www.gnu.org/licenses/agpl-3.0.html).

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc