From 81bf2b646709ee40df13ec1b172ed4d78b35dd9d Mon Sep 17 00:00:00 2001 From: Junio de Souza Date: Fri, 27 Nov 2020 17:32:41 -0300 Subject: [PATCH] event refreshTable --- dist/lets.min.js | 6 +++--- src/directives/crud/lets-crud-list-table.directive.js | 1 + src/views/framework/input.html | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dist/lets.min.js b/dist/lets.min.js index fa71136..a9f0ccc 100644 --- a/dist/lets.min.js +++ b/dist/lets.min.js @@ -1,4 +1,4 @@ !function(){"use strict";function e(){this.headers={};this.set=function(e,t){this.headers[e]=t},this.get=function(e){if(this.headers[e].findLabel=function(e){for(var t in this.fields){var a=this.fields[t];if(a.name==e)return a.label}},this.headers[e].get=function(e){for(var t in this.fields){var a=this.fields[t];if(a.name==e)return a}},this.headers[e].tabs)for(var t in this.headers[e].tabs)this.headers[e].tabs[t].get=function(e){if(!this.fields||!this.fields.length)return null;for(var t in this.fields){var a=this.fields[t];if(a.name==e)return a}};return this.headers[e]},this.$get=function(){return this}}function t(e,t){}var a=angular.module("letsAngular",["ui.router","ngAnimate","ui.bootstrap","angular.viacep","ngCpfCnpj","ui.mask","ui.jq","ui.event","ngFileUpload","moment-filter","checklist-model","ui.toggle","ngSanitize","colorpicker-dr","ckeditor","swangular","colorpicker.module","angularjs-dropdown-multiselect"]);a.config(t),a.provider("headers",e),t.$inject=["$stateProvider","$httpProvider"]}(),function(){"use strict";function e(){var e=this;return e._placeholderList=["paciente"],e._placeholderAttr=["nome"],e.removeAccents=function(e){var t="ÀÁÂÃÄÅàáâãäåßÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž",a="AAAAAAaaaaaaBOOOOOOOooooooEEEEeeeeeCcDIIIIiiiiUUUUuuuuNnSsYyyZz";e=e.split("");var i,n,l=e.length;for(i=0;l>i;i++)-1!=(n=t.indexOf(e[i]))&&(e[i]=a[n]);return e.join("")},e._removeSpecialChars=function(e){var t="!@#$%*()-_+=/.,:;?[{]}`~^|";e=e.split("");var a,i=e.length;for(a=0;i>a;a++)-1!=t.indexOf(e[a])&&(e[a]="");return e.join("")},e.lemmatize=function(t){return t=e.removeAccents(t),e._removeSpecialChars(t)},e.changePlaceholders=function(t,a){return e._placeholderList.forEach(function(i,n){if(a[i]){var l="["+i.toUpperCase()+"]";if(-1!==t.indexOf(l)){var o=t.split(l),r="",s=o.length;o.forEach(function(t,l){r+=t,s-1>l&&(r+=a[i][e._placeholderAttr[n]])}),t=r}}}),t},{removeAccents:e.removeAccents,lemmatize:e.lemmatize,changePlaceholders:e.changePlaceholders}}angular.module("letsAngular").service("utilsStringService",e),e.inject=[]}(),function(){"use strict";function e(e,t,a,i){var n=this;return n._printHTML=function(e){var t=$("").appendTo("body")[0];t.contentWindow.printAndRemove=function(){t.contentWindow.print(),setTimeout(function(){$(t).remove()},3e3)};var a=''+e+"",i=t.contentWindow.document.open("text/html","replace");i.write(a),i.close()},n.print=function(l,o){moment.locale("pt-br");var r=angular.extend(t.$new(),o);e(l).then(function(e){var t=a($("
"+e+"
"))(r),l=function(){r.$$phase?i(l):(n._printHTML(t.html()),r.$destroy())};l()})},{print:n.print}}e.$inject=["$templateRequest","$rootScope","$compile","$timeout"],angular.module("letsAngular").service("utilsPrintService",e),e.inject=["$templateRequest","$rootScope","$compile","$timeout"]}(),function(){"use strict";function e(){var e=this;return e.convertObjSearch=function(e,t){var a={};return Object.keys(e).forEach(function(i){if(e[i])if("object"==typeof e[i]){var n={};Object.keys(e[i]).forEach(function(a){if("createdAt"!==a&&"updatedAt"!==a){var l=a;"id"!==a&&(l="label"),"label"===l&&t&&i===t.relation?n.label=e[i][t.label]:n[l]=e[i][a]}}),a[i+".label"]=n,a[i]=n.id}else-1===i.indexOf("id")&&"createdAt"!==i&&"updatedAt"!==i&&(a[i]=e[i])}),a},e.convertObjLabels=function(e){return e.forEach(function(e){Object.keys(e).forEach(function(t){if("object"==typeof e[t]){var a=t.split(".")[0];"label"===t.split(".")[1]&&(e[a]=angular.copy(e[t]),delete e[t])}})}),e},e.setInputsFromObject=function(e){Object.keys(e).forEach(function(t){if(e[t]&&-1===t.indexOf("hashKey")&&"id"!==t&&"createdAt"!==t&&"updatedAt"!==t){var a=angular.element("#"+t).scope();void 0===a&&-1!==t.indexOf("label")&&(a=angular.element("#"+t.split(".")[0]).scope()),a&&(a.field.autocomplete?"object"==typeof e[t]&&(e[t].label||(e[t].label=e[t].nome),a.$parent.data[t]=e[t].label,a.$parent.data[t+".label"]=e[t]):a.$parent.data[t]=e[t])}})},{convertObjSearch:e.convertObjSearch,convertObjLabels:e.convertObjLabels,setInputsFromObject:e.setInputsFromObject}}angular.module("letsAngular").service("utilsObjectService",e),e.inject=[]}(),function(){"use strict";function e(){var e=this;return e.getDiffDuration=function(e,t,a){moment.isMoment(e)||(e=moment(e)),moment.isMoment(t)||(t=moment(t));var i=moment.duration(e.diff(t));switch(a){case"day":return i.asDays();case"hour":return i.asHours();case"minute":return i.asMinutes();case"second":return i.asSeconds();case"week":return i.asWeeks();case"month":return i.asMonths();case"year":return i.asYears();default:return i.asMilliseconds()}},{getDiffDuration:e.getDiffDuration}}angular.module("letsAngular").service("utilsDateTimeService",e),e.inject=[]}(),function(){"use strict";function e(){var e=this;return e._getFilledFilterAttr=function(e,t){var a={radios:[],checkboxes:[]};return Object.keys(e).forEach(function(t){null!==e[t]&&a.radios.push(t)}),Object.keys(t).forEach(function(e){t[e].length>0&&a.checkboxes.push(e)}),a},e._findCheckAttr=function(e,t){var a=null;return Object.keys(t).forEach(function(i){i===e&&(a=t[i])}),a},e.filterList=function(t,a,i,n,l,o){var r=t.slice(0),s=Object.keys(o).length,c=e._getFilledFilterAttr(a,n),d="neutral";c.checkboxes.forEach(function(e){n[e].length>l[e].length?d="add":n[e].lengtha[t]?1:0}):e},e.getMinMaxValues=function(e,t,a,i,n,l,o){var r={x:o[0][t],y:o[0][n]},s={x:o[0][t],y:o[0][n]};return o.forEach(function(e){e[t]s.x&&(s.x=e[t]),e[n]s.y&&(s.y=e[n])}),"date"===e?(r.x=new Date(moment(r.x).subtract(a,"day").format("MM/DD/YYYY")),s.x=new Date(moment(s.x).add(a,"day").format("MM/DD/YYYY"))):(r.x-=a,s.x+=a),"date"===i?(r.y=new Date(moment(r.y).subtract(l,"day").format("MM/DD/YYYY")),s.y=new Date(moment(s.y).add(l,"day").format("MM/DD/YYYY"))):(r.y-=l,s.y+=l),{min:r,max:s}},{filterList:e.filterList,orderList:e.orderList,getMinMaxValues:e.getMinMaxValues}}angular.module("letsAngular").service("utilsComparatorService",e),e.inject=[]}(),function(){"use strict";function e(e,t,a){var i=this;return i._createModal=function(t){return e.open(t).result},i.createCRUDModal=function(e,a,n,l,o){return i._createModal({animation:!0,templateUrl:l||"lets/views/crud/crud-modal.html",controller:n||"CRUDFormModalController",resolve:{headers:function(){var t=angular.copy(e);return t.parentScope=o,t.get=function(e){for(var a in t.fields){var i=t.fields[a];if(i.name==e)return i}},t},data:function(){try{var e=angular.copy(a)}catch(i){var e=t.extend({},a)}return e},parentScope:o},size:"lg",backdrop:"static",keyboard:!1,windowClass:e.modal_id?"modal-"+e.modal_id:""})},i.hide=function(){a.$emit("cancel-modal")},{createModal:i._createModal,createCRUDModal:i.createCRUDModal,hide:i.hide}}e.$inject=["$modal","jQuery","$rootScope"],angular.module("letsAngular").service("fwModalService",e),e.inject=["$modal","jQuery","$rootScope"]}(),function(){"use strict";function e(e){var t=this;return t.emitFormErrors=function(t){var a=[],i=Object.keys(t.$error),n=/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/;for(var l in i){var o=t.$error[i[l]];for(var r in o){var s=o[r].$options.fieldInfo.label;"required"==i[l]?a.push("O campo "+s+" é obrigatório"):"date"==i[l]&&0==n.test(o[r].$viewValue)&&a.push("O campo "+s+" está com uma data inválida")}}a.length>0&&e.warning(a.join("
"))},{emitFormErrors:t.emitFormErrors}}e.$inject=["ngToast"],angular.module("letsAngular").service("fwErrorService",e),e.inject=["ngToast"]}(),function(){"use strict";function e(){var e=this;return e.configD3chart=function(e,t,a){var i=null,n={left:40,bottom:28,right:28,top:28};return a||(a={x:[],y:[0,150]}),i="multibar"===e?nv.models.multiBarChart().margin(n).color(t).yDomain(a.y):nv.models.lineChart().margin(n).color(t).xDomain(a.x).yDomain(a.y),i.xAxis.showMaxMin(!1).tickFormat(function(e){return d3.time.format("%d/%m/%y")(new Date(e))}),i.xScale(d3.time.scale()),i.yAxis.showMaxMin(!1).tickFormat(d3.format(",f")),i.tooltip.enabled(!1),i},e.configD3chartData=function(e,t,a){var i=[];return a.forEach(function(e){var t={x:new Date(moment(e.data).format("MM/DD/YYYY")),y:e.valor};i.push(t)}),[{area:e,key:t,values:i}]},e.getMockD3chartsData=function(e){return e||(e=!1),{glicemiaCapilar:[{area:e,key:"Valor",values:[{x:new Date("06/10/2017").getTime(),y:77},{x:new Date("06/17/2017").getTime(),y:70},{x:new Date("07/01/2017").getTime(),y:121},{x:new Date("07/08/2017").getTime(),y:84},{x:new Date("07/15/2017").getTime(),y:75},{x:new Date("07/22/2017").getTime(),y:80},{x:new Date("07/29/2017").getTime(),y:76},{x:new Date("08/05/2017").getTime(),y:120},{x:new Date("08/12/2017").getTime(),y:77},{x:new Date("08/19/2017").getTime(),y:85}]}],pressao:[{area:e,key:"Sistólica",values:[{x:new Date("06/10/2017").getTime(),y:125},{x:new Date("06/17/2017").getTime(),y:139},{x:new Date("07/01/2017").getTime(),y:129},{x:new Date("07/08/2017").getTime(),y:133},{x:new Date("07/15/2017").getTime(),y:134},{x:new Date("07/22/2017").getTime(),y:133},{x:new Date("07/29/2017").getTime(),y:143},{x:new Date("08/05/2017").getTime(),y:148},{x:new Date("08/12/2017").getTime(),y:139},{x:new Date("08/19/2017").getTime(),y:134}]},{area:e,key:"Diastólica",values:[{x:new Date("06/10/2017").getTime(),y:78},{x:new Date("06/17/2017").getTime(),y:75},{x:new Date("07/01/2017").getTime(),y:83},{x:new Date("07/08/2017").getTime(),y:80},{x:new Date("07/15/2017").getTime(),y:77},{x:new Date("07/22/2017").getTime(),y:79},{x:new Date("07/29/2017").getTime(),y:83},{x:new Date("08/05/2017").getTime(),y:81},{x:new Date("08/12/2017").getTime(),y:74},{x:new Date("08/19/2017").getTime(),y:81}]}],peso:[{area:e,key:"Quilos",values:[{x:new Date("06/10/2017").getTime(),y:89},{x:new Date("06/17/2017").getTime(),y:90},{x:new Date("07/01/2017").getTime(),y:89},{x:new Date("07/08/2017").getTime(),y:92},{x:new Date("07/15/2017").getTime(),y:93},{x:new Date("07/22/2017").getTime(),y:94},{x:new Date("07/29/2017").getTime(),y:93},{x:new Date("08/05/2017").getTime(),y:93},{x:new Date("08/12/2017").getTime(),y:93},{x:new Date("08/19/2017").getTime(),y:92}]}],altura:[{area:e,key:"Metros",values:[{x:new Date("06/10/2017").getTime(),y:1.76},{x:new Date("06/17/2017").getTime(),y:1.76},{x:new Date("07/01/2017").getTime(),y:1.76},{x:new Date("07/08/2017").getTime(),y:1.76},{x:new Date("07/15/2017").getTime(),y:1.76},{x:new Date("07/22/2017").getTime(),y:1.76},{x:new Date("07/29/2017").getTime(),y:1.76},{x:new Date("08/05/2017").getTime(),y:1.76},{x:new Date("08/12/2017").getTime(),y:1.76},{x:new Date("08/19/2017").getTime(),y:1.76}]}],imc:[{area:e,key:"Valor",values:[{x:new Date("06/10/2017").getTime(),y:15.3},{x:new Date("06/17/2017").getTime(),y:15.5},{x:new Date("07/01/2017").getTime(),y:15.3},{x:new Date("07/08/2017").getTime(),y:15.8},{x:new Date("07/15/2017").getTime(),y:16},{x:new Date("07/22/2017").getTime(),y:16.2},{x:new Date("07/29/2017").getTime(),y:16},{x:new Date("08/05/2017").getTime(),y:16},{x:new Date("08/12/2017").getTime(),y:16},{x:new Date("08/19/2017").getTime(),y:15.8}]}],hdlLdl:[{area:e,key:"HDL",values:[{x:new Date("06/10/2017").getTime(),y:43},{x:new Date("06/17/2017").getTime(),y:41},{x:new Date("07/01/2017").getTime(),y:42},{x:new Date("07/08/2017").getTime(),y:45},{x:new Date("07/15/2017").getTime(),y:46},{x:new Date("07/22/2017").getTime(),y:48},{x:new Date("07/29/2017").getTime(),y:44},{x:new Date("08/05/2017").getTime(),y:41},{x:new Date("08/12/2017").getTime(),y:42},{x:new Date("08/19/2017").getTime(),y:40}]},{area:e,key:"LDL",values:[{x:new Date("06/10/2017").getTime(),y:121},{x:new Date("06/17/2017").getTime(),y:130},{x:new Date("07/01/2017").getTime(),y:137},{x:new Date("07/08/2017").getTime(),y:138},{x:new Date("07/15/2017").getTime(),y:120},{x:new Date("07/22/2017").getTime(),y:122},{x:new Date("07/29/2017").getTime(),y:123},{x:new Date("08/05/2017").getTime(),y:124},{x:new Date("08/12/2017").getTime(),y:122},{x:new Date("08/19/2017").getTime(),y:120}]}]}},e.getMockD3chartsConfig=function(){return{glicemiaCapilar:e.configD3chart("line",["#092e64"],{x:[new Date("06/10/2017"),new Date("08/09/2017")],y:[50,130]}),pressao:e.configD3chart("line",["#092e64","#008df5"],{x:[new Date("06/10/2017"),new Date("08/09/2017")],y:[50,150]}),peso:e.configD3chart("line",["#092e64"],{x:[new Date("06/10/2017"),new Date("08/09/2017")],y:[80,100]}),altura:e.configD3chart("line",["#092e64"],{x:[new Date("06/10/2017"),new Date("08/09/2017")],y:[0,2]}),imc:e.configD3chart("line",["#092e64"],{x:[new Date("06/10/2017"),new Date("08/09/2017")],y:[12,20]}),hdlLdl:e.configD3chart("line",["#092e64","#008df5"],{x:[new Date("06/10/2017"),new Date("08/09/2017")],y:[30,150]})}},{getMockD3chartsData:e.getMockD3chartsData,getMockD3chartsConfig:e.getMockD3chartsConfig,configD3chart:e.configD3chart,configD3chartData:e.configD3chartData}}angular.module("letsAngular").service("fwChartService",e),e.inject=[]}(),function(){"use strict";function e(e,t,a,i,n,l,o,r){var s=l.API_URL,c=this;c.updateLocalStorage=function(e,t){var a=c.getUser();a[e]=t,c.setUserInfo(a)},c.setUserLb=function(e){t.setUser(e.id,e.userId,e.user),t.rememberMe=!0,t.save()},c.setUserInfo=function(e){window.localStorage.user=angular.toJson(e)},c.getUser=function(){return window.localStorage.user?JSON.parse(window.localStorage.user):!1},c.isAuthenticated=function(){return null!=t.currentUserId},c.authenticate=function(e){return n.authenticate(e).then(function(e){var t={accessToken:e.access_token};return o.post(s+"users/facebook/token",t)}).then(function(e){var t={id:e.data.id,userId:e.data.user.id,user:e.data.user};c.setUserLb(t),c.setUserInfo(e.data.user),c.removeSatellizer(),i.go("main.search")})["catch"](function(e){console.debug(e)})},c.logout=function(n){a.userLogout({accessToken:n}).$promise.then(function(a){t.clearUser(),t.clearStorage(),e.localStorage.removeItem("user"),i.go("login")})["catch"](function(a){t.clearUser(),t.clearStorage(),e.localStorage.removeItem("user"),i.go("login")})},c.getCurrentUserId=function(){return t.currentUserId},c.getCurrentUserToken=function(){return t.accessTokenId},c.removeSatellizer=function(){e.localStorage.getItem("satellizer_token")&&e.localStorage.removeItem("satellizer_token")}}e.$inject=["$window","LoopBackAuth","Usuario","$state","$auth","appSettings","$http","$q"],angular.module("letsAngular").service("fwAuthService",e),e.inject=["$window","LoopBackAuth","Usuario","$state","$auth","appSettings","$http"]}(),function(){"use strict";var e={navy:"#001f3f",blue:"#0074D9",aqua:"#7FDBFF",teal:"#39CCCC",olive:"#3D9970",green:"#2ECC40",lime:"#01FF70",yellow:"#FFDC00",orange:"#FF851B",red:"#FF4136",maroon:"#85144b",fuchia:"#F012BE",purple:"#B10DC9",black:"#111111",gray:"#AAAAAA",white:"#FFFFFF"},t=function(t,a,i){return{restrict:"A",require:"ngModel",scope:{changeColor:"&",tinyTrigger:"@",colorMe:"@",ngModel:"=",setColors:"@"},link:function(n,l,o,r){var s=0,c="";if(n.setColors)n.setColors=JSON.parse(n.setColors),n.setColors.forEach(function(t){0==s?(c+='
',s++):3==s?(c+='
',s=0):(c+='',s++)},this);else for(var d in e)0==s?(c+='
',s++):3==s?(c+='
',s=0):(c+='',s++);var u,f,p,m,g,b='
',h='
',v='
';g=function(e){if(e.previousElementSibling)return e.previousElementSibling;for(;e=e.previousSibling;)if(1===e.nodeType)return e},m=function(e,t){for(var a=!1;void 0!==e.parent()&&a===!1;)e.parent().hasClass(t)&&(a=!0),e=e.parent();return e},void 0!==n.tinyTrigger&&"true"===n.tinyTrigger?(v=v.replace("picker-icon","picker-icon trigger"),f=t(v)(n),l.replaceWith(f),c=b+c,p=angular.element(c),p.find("cp-color").on("click",function(e){r.$setViewValue(angular.element(e.target).attr("color"))}),angular.element(document.body).append(p),f.bind("click",function(e){if(0==angular.element(e.target).prop("readonly")){var t=m(angular.element(e.target),"color-picker-wrapper"),a=t[0].getBoundingClientRect().top,n=t[0].getBoundingClientRect().height;a+=i.pageYOffset,p.removeClass("hide"),p[0].style.top=a+n+"px",p[0].style.left=t[0].getBoundingClientRect().left+"px",e.stopPropagation()}})):"INPUT"===l[0].tagName?(c=b+c,p=angular.element(c),p.find("cp-color").on("click",function(e){var t=angular.element(e.target).attr("color");r.$setViewValue(t),void 0!==n.colorMe&&"true"===n.colorMe?l[0].style.backgroundColor=t:l.val(t)}),n.$watch("ngModel",function(e,t){var a=e;void 0!=a&&void 0!==n.colorMe&&"true"===n.colorMe&&(l[0].style.backgroundColor=a,l[0].value="")}),angular.element(document.body).append(p),l.bind("click",function(e){if(0==angular.element(e.target).prop("readonly")){var t=e.target.getBoundingClientRect().top,a=e.target.getBoundingClientRect().height;t+=i.pageYOffset,p.removeClass("hide"),p[0].style.top=t+a+"px",p[0].style.left=e.target.getBoundingClientRect().left+"px",e.stopPropagation()}}),f=t(v)(n),l.after(f),f.bind("click",function(e){var t=m(angular.element(e.target),"color-picker-wrapper"),a=g(t[0]),n=a.getBoundingClientRect().top,l=a.getBoundingClientRect().height;n+=i.pageYOffset,p.removeClass("hide"),p[0].style.top=n+l+"px",p[0].style.left=a.getBoundingClientRect().left+"px",e.stopPropagation()}),t(u)(n)):(c=h+c,p=t(c)(n),l.replaceWith(p),p.find("cp-color").on("click",function(e){r.$setViewValue(angular.element(e.target).attr("color")),e.stopPropagation()})),a.bind("click",function(e){var t,i=a.find("body").children();for(t=0;t0&&(i.errFile=a&&a[0],a.forEach(function(e){"pattern"==e.$error&&(i.field.error="O formato do arquivo não é permitido.")})),t&&(i.field.error=null,i.f.name=t.name,i.f.uploading=!0,i._upload(i.field,t).then(function(t,a){i.$emit("upload-complete",t),e(function(){i.f.progress=100,i.f.alreadySent=!0,i.f.uploading=!1,i.f.name=t.data.result.files.file[0].name,i.f.fileURL=o+i.f.name,i.f.isImage=i.isFileImage(i.f.name),l.controller("ngModel").$setViewValue(i.f.name)})},function(t){console.log(t),t.status>0&&(i.errorMsg=t.status+": "+t.data),i.$emit("upload-error",t),e(function(){i.field.error="Ocorreu um erro ao enviar o arquivo.",i.f={}})},function(t){e(function(){i.f.progress=Math.min(90,parseInt(100*t.loaded/t.total))})}))},i.dropFile=function(e,t){i.upload(e,t)}}}}angular.module("letsAngular").directive("fwUpload",e),e.$inject=["$timeout","appSettings","$sce"]}(),function(){"use strict";function e(){return{restrict:"E",scope:{tags:"="},template:'
{{tag}} ×
',link:function(e,t){null==e.tags&&(e.tags=[]);var a=angular.element(t).find("input");e.autocomplete,e.add=function(){-1==e.tags.indexOf(e.newValue)&&e.tags.push(e.newValue),e.newValue=""},e.remove=function(t){e.tags.splice(t,1)},a.bind("keypress",function(t){13==t.keyCode&&(t.stopPropagation(),t.preventDefault(),e.$apply(e.add))})}}}angular.module("letsAngular").directive("fwTags",e),e.$inject=[]}(),function(){"use strict";function e(){return{templateUrl:"lets/views/framework/paginator.html",replace:!0,scope:{totalrecords:"=",pagesize:"=",currentpage:"=",totalpages:"=",gopage:"="},controller:["$scope",function(e){e.itemsize=9,e.go=function(t){t!=e.currentpage&&t>=1&&t<=e.totalpages&&(e.gopage(t),window.scrollTo({top:100,behavior:"smooth"}))},e.getPages=function(){var t=[];if(e.currentpage){var a=Math.ceil(e.itemsize/2);a=e.currentpage-a<=0?1:e.currentpage-a;var i=a+e.itemsize;i=Math.min(i,e.totalpages),e.totalpages>e.itemsize&&i-a=n;n++)t.push(n)}return t}}],link:function(e,t){}}}angular.module("letsAngular").directive("fwPaginator",e),e.$inject=[]}(),function(){"use strict";angular.module("letsAngular").directive("numbersOnly",function(){return{require:"ngModel",link:function(e,t,a,i){function n(e){if(e){var t=e.replace(/[^0-9]/g,"");return t!==e&&(i.$setViewValue(t),i.$render()),t}return void 0}i.$parsers.push(n)}}})}(),function(){"use strict";function e(e,t,a){return{restrict:"A",priority:1,link:function(e,t){e.dataReference=$(t)},controller:["$scope","$state",function(e,i){e.initMultiSelect=!1,e.msmodel=[],e.filter={},e.msdata=[],e.setting={};var n="";e.$on("filter-init",function(t){var a=t.targetScope.data||void 0,i=$(e.dataReference).attr("data-reference")||void 0;n=i,i&&a&&(e.msmodel=angular.copy(a[i])||[])}),e.changedMultiSelect=function(t){e.msmodel.length?angular.element(".fw-multiselect-button").css("color","#555555"):angular.element(".fw-multiselect-button").css("color","#CCC")},e.onItemSelect=function(t,a){e.data[n]=e.msmodel;var i=e.msdata.find(function(e){return e.id==t.id});t.label=i.label},e.onItemDeselect=function(e){},e.removeDuplicates=function(e,t){return e.filter(function(e,a,i){return i.map(function(e){return e[t]}).indexOf(e[t])===a})},e.makeRequestAutocomplete=function(i,n,l,o){t(function(){n||(n="[blank]");var r=o?"general/":"";e.resource=a.all(e.route()),e.resource.customGET(r+"autocomplete/"+l+"/"+n+"?limit=10").then(function(a){i.options=e.removeDuplicates(a.concat(i.selectedModel),"id"),t(function(){},0)},function(){})})},e._debounce=function(e){var t=null;return function(a){t&&clearTimeout(t),t=setTimeout(function(){e(a)},200)}},e.openDropdownByButton=function(e){t(function(){$('[data-reference="'+e+'"] button').click()})},e.onInitMulti=function(t,a){var i=$(t.target);i.scope().input.searchFilter="";var n=a.customOptions.general?a.customOptions.general:a.name,l=a.customOptions.general?!0:!1;if(!i.initMultiSelect){var o=i.scope();i.initMultiSelect=!0,e.makeRequestAutocomplete(o,"[blank]",n,l),i.parent().find(".dropdown-header").append(''),o.$watch("input.searchFilter",e._debounce(function(t){e.makeRequestAutocomplete(o,t,n,l)})),o.texts.buttonDefaultText="Selecione "+a.label,o.texts.searchPlaceholder="Buscar "+a.label,o.texts.dynamicButtonTextSuffix="selecionado(s)",o.externalEvents.onItemSelect=e.onItemSelect,o.externalEvents.onSelectionChanged=e.changedMultiSelect,o.externalEvents.onItemDeselect=e.onItemDeselect}},e.mssettings={scrollableHeight:"200px",scrollable:!0,buttonDefaultText:"Tipos de imóveis",enableSearch:!0,styleActive:!0,showCheckAll:!1,showUncheckAll:!1,selectedToTop:!0,buttonClasses:"btn btn-default fw-multiselect-button"}}]}}angular.module("letsAngular").directive("fwMultiSelect",e),e.$inject=["$compile","$timeout","Restangular","$state"]}(),function(){"use strict";function e(e,t,a,i,n){return{restrict:"E",scope:!0,templateUrl:"lets/views/framework/input.html",replace:!0,link:{pre:function(t,l,o,r){var s=l.attr("fw-data");if(void 0==t.field.customOptions.events&&(t.field.customOptions.events={}),t.fieldHtml=function(){return n.trustAsHtml(t.field.toString())},"data"!=s&&(t.data=t[s]),"detail_data"==s){var c=t.detail_key;t.field.autocomplete!==!1&&(t.autocomplete=function(e,a){return t.autocompleteDetail(c,e,a)},t.autocompleteSelect=function(e,a,i){return t.autocompleteDetailSelect(c,e,a,i)}),void 0!=t.field.customOptions.file&&(t.download=function(e,a){return t.downloadDetail(c,e,a,t.data)})}if(void 0!=t.field.customOptions.cep)l.find("input.main-input").blur(function(){var a=angular.element(this).scope();e.get(this.value).then(function(e){var i=a.field.customOptions.cep;a.data[i.address]=e.logradouro,a.data[i.district]=e.bairro,a.data[i.city]=e.localidade,a.data[i.state]=e.uf,t.$$phase||t.$apply()})});else if(void 0!=t.field.customOptions.multiple&&1==t.field.customOptions.multiple){a(l.contents())(t)}i(l).on("blur",":input[ng-model]",function(e){try{void 0!=angular.element(this).scope().field.customOptions.events.blur&&angular.element(this).scope().field.customOptions.events.blur.call(this,e)}catch(e){}}),t.isEmpty=function(e){return Object.keys(e).length}}}}}angular.module("letsAngular").directive("fwInput",e),e.$inject=["viaCEP","$timeout","$compile","jQuery","$sce"]}(),function(){"use strict";function e(e,t,a,i){return{restrict:"E",scope:!0,templateUrl:"lets/views/framework/input-detail.html",replace:!0,link:{post:function(e,t,a,i){}}}}angular.module("letsAngular").directive("fwInputDetail",e),e.$inject=["viaCEP","$timeout","$compile","jQuery"]}(),function(){"use strict";function e(e,t,a,i,n){return{restrict:"A",link:{post:function(a,n,l,o){if(o||(o=n.controller("ngModel")),"date"==a.field.type)n.mask("99/99/9999");else if(void 0!=a.field.customOptions.cpf)n.mask("999.999.999-99");else if(void 0!=a.field.customOptions.cnpj)n.mask("99.999.999/9999-99");else if(void 0!=a.field.customOptions.customMask)n.mask(a.field.customOptions.customMask);else if("float"==a.field.type)void 0!=a.field.customOptions.currency&&(n.mask("#.##0,00",{reverse:!0}),o.$parsers.unshift(function(e){return parseFloat(n.cleanVal(),10)/100}),o.$formatters.unshift(function(e){return n.masked(e?parseFloat(e).toFixed(2):null)}));else if(void 0!==a.field.customOptions.documento){var r=function(e){return e.replace(/\D/g,"").length>=12?"00.000.000/0000-00":"000.000.000-009"},s={onKeyPress:function(e,t,a,i){a.mask(r.apply({},arguments),i)}};t(function(){n.mask(r,s)},10)}else if(void 0!=a.field.customOptions.telefone){var c=function(e){return 11===e.replace(/\D/g,"").length?"(00) 00000-0000":"(00) 0000-00009"},d={onKeyPress:function(e,t,a,i){a.mask(c.apply({},arguments),i)}};t(function(){n.mask(c,d)},100)}else void 0!=a.field.customOptions.cep&&n.blur(function(){if(!this.value)return!1;var t=angular.element(this).scope();i(this).parent().attr("fw-data");e.get(this.value).then(function(e){var a=t.field.customOptions.cep;t.data[a.address]=e.logradouro,t.data[a.district]=e.bairro,t.data[a.city]=e.localidade,t.data[a.state]=e.uf,t.data[a.ibge]=e.ibge,t.data[a.gia]=e.gia,t.$emit("viacep complete",e)})})}}}}angular.module("letsAngular").directive("fwDynamic",e),e.$inject=["viaCEP","$timeout","$compile","jQuery","$filter"]}(),function(){"use strict";function e(e,t,a,i,n){return{restrict:"E",scope:!0,template:'',replace:!0,link:{pre:function(t,a,i,l){t.formatData=function(t,a){if(a.autocomplete!==!1)return t[a.name+".label"]?t[a.name+".label"].label||t[a.name+".label"]:null;if("date"==a.type)return a.customOptions.hour?moment(t[a.name]).format("DD/MM/YYYY HH:mm"):moment(t[a.name]).format("DD/MM/YYYY");if("time"==a.type)return moment(t[a.name]).format("HH:mm");if("boolean"!=a.type){if("string"==a.type&&a.customOptions.file){var i=e.appSettings.API_URL+"upload/"+a.customOptions.file.container+"/download/"+t[a.name];return n.trustAsHtml('')}if("float"==a.type){if(a.customOptions&&a.customOptions.currency){var l=t[a.name],l=l.toFixed(2).split(".");return l[0]="R$ "+l[0].split(/(?=(?:...)*$)/).join("."),l.join(",")}return t[a.name]}if("custom"==a.type){var o=a.toString({attributes:t});return o&&o[0]&&o[0].outerHTML?n.trustAsHtml(o[0].outerHTML):""}return t[a.name]}return a.customOptions.statusFalseText&&a.customOptions.statusTrueText?t[a.name]?a.customOptions.statusTrueText:a.customOptions.statusFalseText:void 0}}}}}angular.module("letsAngular").directive("fwDetailData",e),e.$inject=["$rootScope","$timeout","$compile","jQuery","$sce"]}(),function(){"use strict";function e(e,t){var a="vm";return{restrict:"A",require:"?ngModel",scope:!0,terminal:!0,priority:1,compile:function(t,i){function n(e,a){var i=t.attr(e);angular.isDefined(i)&&i!==!1||t.attr(e,a)}var l=angular.element('
');return n("type","text"),n("is-open",a+".popupOpen"),n("show-button-bar",!1),n("show-weeks",!1),n("datepicker-options","datepickerOptions"),t.addClass("form-control"),t.removeAttr("fw-date-picker"),t.after(l),l.prepend(t),function(t,a){var n={};void 0===t.data&&(t.data={}),t.field?null!=t.data[t.field.name]&&(n.initDate=new Date(t.data[t.field.name]),t.data[t.field.name]=angular.copy(n.initDate)):(t.field={customOptions:[]},i.fwDatePickerNgModelParent?(n.initDate=new Date(t.$parent[i.ngModel]),t.$parent[i.ngModel]=angular.copy(n.initDate)):(n.initDate=new Date(t[i.ngModel]),t[i.ngModel]=angular.copy(n.initDate)));var l="dd/MM/yyyy";void 0!==t.field.customOptions.monthpicker&&(n.datepickerMode="'month'", -n.minMode="month",l="MM/yyyy"),a.find("input").attr("datepicker-popup",l),a.find("input").blur(function(){moment(this.value,l).isValid()||""===this.value?t.field.error=!1:t.field.error=!0}),t.datepickerOptions=n,e(a)(t)}},controller:["$scope",function(e){this.popupOpen=!1,this.openPopup=function(e){e.preventDefault(),e.stopPropagation(),this.popupOpen=!0}}],controllerAs:a}}angular.module("letsAngular").directive("fwDatePicker",e),e.$inject=["$compile","jQuery"]}(),function(e,t){"function"==typeof define&&define.amd?define(["angular"],t):t(angular)}(this,function(e){function t(e){return{restrict:"A",require:["ckeditor","ngModel"],controller:["$scope","$element","$attrs","$parse","$q",a],link:function(t,a,n,l){var o=l[0],r=l[1];o.ready().then(function(){["dataReady","change","blur","saveSnapshot"].forEach(function(e){o.onCKEvent(e,function(){r.$setViewValue(o.instance.getData()||"")})}),o.instance.setReadOnly(!!n.readonly),n.$observe("readonly",function(e){o.instance.setReadOnly(!!e)}),i(function(){e(n.ready)(t)})}),r.$render=function(){o.ready().then(function(){o.instance.setData(r.$viewValue||"",{noSnapshot:!0,callback:function(){o.instance.fire("updateSnapshot")}})})}}}}function a(e,t,a,n,l){var o,r=n(a.ckeditor)(e)||{},s=t[0],c=l.defer();o=s.hasAttribute("contenteditable")&&"true"==s.getAttribute("contenteditable").toLowerCase()?this.instance=CKEDITOR.inline(s,r):this.instance=CKEDITOR.replace(s,r),this.onCKEvent=function(t,a){function n(){var e=arguments;i(function(){l.apply(null,e)})}function l(){var t=arguments;e.$apply(function(){a.apply(null,t)})}return o.on(t,n),function(){o.removeListener(t,l)}},this.onCKEvent("instanceReady",function(){c.resolve(!0)}),this.ready=function(){return c.promise},e.$on("$destroy",function(){c.promise.then(function(){o.destroy(!1)})})}e.module("ckeditor",[]).directive("ckeditor",["$parse",t]);var i=window&&window.setImmediate?window.setImmediate:function(e){setTimeout(e,0)}}),function(){"use strict";function e(e,t,a){return{restrict:"E",replace:!1,scope:{crudChartSettings:"&",crudChartData:"&"},templateUrl:"lets/views/framework/chart.html",controller:["$scope",function(i){var n=i.crudChartSettings(),l=n.chart_settings,o=i.crudChartData();i.key=n.key,i.d3chartUpdate=!1;var r=t.getMinMaxValues(l.xType,l.xLabel,l.xOffset,l.yType,l.yLabel,l.yOffset,o),s={x:[r.min.x,r.max.x],y:[r.min.y,r.max.y]};i.d3chartStartDate=r.min.x,i.d3chartEndDate=r.max.x,i.d3chartConfig=e.configD3chart("line",["#092e64"],s),i.d3chartData=e.configD3chartData(n.fillArea||!1,n.key,o),i.$watch("d3chartStartDate",function(t,n){r.min.x=t,s={x:[r.min.x,r.max.x],y:[r.min.y,r.max.y]},i.d3chartConfig=e.configD3chart("line",["#092e64"],s),t!=n&&a.$broadcast("update-chart",{type:"filter"})}),i.$watch("d3chartEndDate",function(t,n){r.max.x=t,s={x:[r.min.x,r.max.x],y:[r.min.y,r.max.y]},i.d3chartConfig=e.configD3chart("line",["#092e64"],s),t!=n&&a.$broadcast("update-chart",{type:"filter"})})}],link:function(e,t,a,i,n){e.$el=t}}}angular.module("letsAngular").directive("fwChart",e),e.$inject=["fwChartService","fwComparatorService","$rootScope"]}(),function(){"use strict";function e(e,t){var a="vm";return{restrict:"A",priority:1,link:function(e,a){var i=a.find("input"),n=function(){i.val()||(i.controller("ngModel").$setViewValue(void 0),t(function(){i.controller("ngModel").$setViewValue("")}))};a.find("button").click(n),i.click(n),i.keyup(function(){""==this.value.trim()&&(i.scope().data[i.attr("name")]=null)}),a.find(".icon.fa-close").click(function(){i.scope().data[i.attr("name")]=null,i.scope().data[i.attr("name")+".label"]=null,i.scope().autocompleteSelect({id:null},{id:null}),i.val(""),i.controller("ngModel").$setViewValue("")})},controller:function(){},controllerAs:a}}angular.module("letsAngular").directive("fwAutoComplete",e),e.$inject=["$compile","$timeout"]}(),function(){"use strict";function e(e,t,a,i){var n="vm";return{restrict:"A",priority:1,link:function(e,i){var n=e;n.tableSelected=function(e,t,a){n.tableVisibily=!1;var i=e.currentTarget.firstElementChild.firstChild.data.trim();n.data[t]=a.id,n.data[t+".labelCopy"]={id:a.id,label:i},n.data[t+".label"]=i},n.loadDataAutoCompleteTable=function(e,l){var o=i.find(":input").val().split(" "),r="/^("+o[0]+")";o.splice(0,1),o.forEach(function(e){r+="(?=.*"+e+")"}),r+=".*/i";var s='{"limit": 5,"where":{"'+l+'":{"regexp":"'+r+'"}}}',c=t.appSettings.API_URL+e+"?filter="+s,d=t.appSettings.API_URL+e+"/crudGET/";a.get(c).then(function(e){n.autoCompleteTableData2=[],e.data.forEach(function(e){a.get(d+e.id).then(function(e){n.autoCompleteTableData2.push(e.data)})})})}},controller:["$scope",function(e){e.autoCompleteTableFocus=function(t){e.tableVisibily=!0},e.autoCompleteTableLostFocus=function(){setTimeout(function(){e.$apply(function(){e.tableVisibily=!1})},100)},e.updateAutoCompleteTable=function(t,a){e.loadDataAutoCompleteTable(t,a)}}],controllerAs:n}}angular.module("letsAngular").directive("fwAutoCompleteTable",e),e.$inject=["$compile","$rootScope","$http","$timeout"]}(),function(){"use strict";function e(e){return{scope:{crudTabListData:"=",crudTabListSettings:"&",parentData:"="},templateUrl:"lets/views/crud/crud-tab-list.html",link:function(e,t){setTimeout(function(){var t=e.crudTabListSettings();e.data=e.parentData,e.type=t.type,e.headers=t.headers,e.app=e.$parent.app,e.crudTabListData&&(e.extraData=e.crudTabListData)},1e3)}}}angular.module("letsAngular").directive("crudTabList",e),e.$inject=["jQuery"]}(),function(){"use strict";function e(e,t,a,i,n,l,o,r){return{scope:{crudListSettings:"&",crudListDependenciesData:"&",app:"="},controller:["$scope",function(e){e.route=null,e.$on("refreshGRID",function(t,a,i){e.pageableCRUDModel.fetch(null,a,i)}),e.$on("renderGRID",function(t){e.renderGRID()})}],link:function(l,s,c){function d(){function s(e){var a=[],n=function(){};n.prototype=new i.StringFormatter,_.extend(n.prototype,{fromRaw:function(e,t,a,i,n){return e}}),_.each(c.fields,function(e,t){if(e.viewable){var n={name:e.name,label:e.label,cell:"string",editable:!1,headers:e};if("boolean"==e.type)n.sortable=!1,n.cell=i.Cell.extend({className:"custom-situation-cell",formatter:{fromRaw:function(t,a){return t?e.customOptions.statusTrueText:e.customOptions.statusFalseText},toRaw:function(e,t){return"down"}}});else if("simplecolor"==e.type)n.sortable=!1,n.cell=i.Cell.extend({className:"custom-situation-cell",initialize:function(){i.Cell.prototype.initialize.apply(this,arguments)},render:function(){this.$el.empty();var e='';return this.$el.append(e),this.delegateEvents(),this}});else if("custom"==e.type){var l={fromRaw:e.toString,toRaw:function(e,t){return"down"}};n.sortable=!1;var o=i.Cell.extend({className:"custom-cell",formatter:l});o.initialize=function(){i.Cell.prototype.initialize.apply(this,arguments)},o.render=function(){this.$el.empty(),this.$el.data("model",this.model);var e=l.fromRaw(this.model);return this.$el.append(e),this.delegateEvents(),this},n.cell=i.Cell.extend(o)}else if("address"==e.type){var r={fromRaw:function(e,t){try{return e.city+" - "+e.state}catch(a){return""}},toRaw:function(e,t){return"down"}},s=i.Cell.extend({className:"address-cell",formatter:r});n.cell=s}else if("float"==e.type)e.customOptions&&e.customOptions.currency?n.cell=i.Cell.extend({formatter:{fromRaw:function(e,t){if(e){var e=e.toFixed(2).split(".");return e[0]="R$ "+e[0].split(/(?=(?:...)*$)/).join("."),e.join(",")}}}}):n.cell=i.NumberCell.extend({decimalSeparator:",",orderSeparator:"."});else if("date"==e.type){var c="DD/MM/YYYY",d="YYYY/M/D",u=!0;void 0!==e.customOptions.monthpicker&&(c="MM/YYYY"),e.customOptions.timestamp&&(d="YYYY/M/D HH:mm:ss.SSS",u=!1),n.cell=i.Extension.MomentCell.extend({modelFormat:d,displayLang:"pt-br",displayFormat:c,displayInUTC:u})}else if(void 0!=e.customOptions["enum"]){var f=[];for(var p in e.customOptions["enum"]){var m=e.customOptions["enum"][p];f.push([m,p])}n.cell=i.SelectCell.extend({optionValues:f})}else 1==e.autocomplete&&(e.customOptions&&void 0!=e.customOptions.list?n.cell=i.Cell.extend({className:"custom-situation-cell-select",formatter:{fromRaw:function(t,a){var i="";return e.customOptions.list.forEach(function(e){e.id==t&&(i=e.label)}),i},toRaw:function(e,t){return"down"}}}):n.name=n.name+".label");a.push(n)}});var o=i.Cell.extend({className:"text-right btn-column"+(1==c.tab?" detail":""),template:function(){var e=[];if(c.tab)if(c.settings){if(c.settings.edit){var a=t('');a.attr("data-route",c.url),e.push(a)}if(c.settings["delete"]){var i=t('');i.attr("data-route",c.url),e.push(i)}}else{var i=t('');i.attr("data-route",c.url),e.push(i)}else c.settings.edit&&e.push(t('')),c.settings["delete"]&&e.push(t(''));var n=t('
');return n.append(e),n},events:{},editRow:function(e){e.preventDefault()},render:function(){var e=this.template(this.model.toJSON());return this.$el.html(e),this.$el.data("model",this.model),this.$el.find("button.btn-edit").click(function(e){e.stopPropagation();var t=angular.element(this).scope();c.tab?t.$parent.edit($(this).closest("td").data("model").attributes):t.edit($(this).closest("td").data("model").attributes)}),this.$el.find("button.btn-delete").click(function(e){e.stopPropagation();var t=window.confirm(u.translate("letsfw.message_delete"));if(t){var a=angular.element(this).scope();c.tab?a.$parent["delete"]($(this).closest("td").data("model").attributes):a["delete"]($(this).closest("td").data("model").attributes)}}),this.$el.find("button.btn-delete-detail").click(function(e){e.stopPropagation();var a=window.confirm(u.translate("letsfw.message_delete"));if(a){var i=angular.element(this).scope(),n=t(this).attr("data-route");c.tab?i.$parent.deleteDetail(n,$(this).closest("td").data("model").attributes):i.deleteDetail(n,$(this).closest("td").data("model").attributes)}}),this.$el.find("button.btn-edit-detail").click(function(e){e.stopPropagation();var t=angular.element(this).scope(),a=$.parseJSON($(this).closest(".table-container").attr("tab-config")),i=$(this).closest("td").data("model").attributes,n=$(this).attr("data-route");t.newDetail(a,t.data,i.id,n)}),this.delegateEvents(),this}});(c.settings.edit||c.settings["delete"])&&a.push({name:"actions",label:u.translate("letsfw.actions"),sortable:!1,cell:o}),l.$parent.app.helpers.isScreen("xs")&&a.splice(3,1);var r=[];1==c.tab&&r.push("detail"),void 0==c.settings||c.settings.edit||r.push("cant-edit");var s=i.Row.extend({className:r.join(" ")}),d="table table-striped table-editable no-margin mb-sm";c.tableClass&&(d+=" "+c.tableClass);var f=new i.Grid({row:s,columns:a,collection:e,className:d}),p=new i.Extension.Paginator({slideScale:.25,goBackFirstOnSort:!1,collection:e,controls:{rewind:{label:'',title:"First"},back:{label:'',title:"Previous"},forward:{label:'',title:"Next"},fastForward:{label:'',title:"Last"}}});l.$el.find(".table-container").html("").append(f.render().$el).append(p.render().$el),setTimeout(function(){angular.element(p.render().$el).click(function(){window.scrollTo({top:100,behavior:"smooth"})})},0),l.$broadcast("refreshGRID",!0)}var c=l.crudListSettings();c.route=n.API_URL+c.url,l.route=c.route,i.InputCellEditor.prototype.attributes["class"]="form-control input-sm";var d=a.Model.extend({}),f={model:d,url:c.route+(c.pagerGeneral?"/pagerGeneral":"/pager"),state:{pageSize:20},mode:"server",parseRecords:function(e,t){return l.$el[0].parseRecords&&"function"==typeof l.$el[0].parseRecords?l.$el[0].parseRecords(e.data):e.data},parseState:function(e,a,i,n){return o(function(){var a=t("
    ");a.append(t("
  • ").html(u.translate("letsfw.records_page")+": "+e.total_entries+" / "+e.total_count)),l.$el.find(".table-container .backgrid-paginator ul.total-records").remove(),l.$el.find(".table-container .backgrid-paginator").append(a)}),l.$parent.totalPager=e.total_count,{totalRecords:e.total_count}}};c.filterScope&&(f.queryParams={scope:c.filterScope}),c.sort&&(f.state.sortKey=c.sort.sortKey,c.sort.order&&"desc"==c.sort.order&&(f.state.order=1));var p=a.PageableCollection.extend(f),m=new p;l.pageableCRUDModel=m;var g=angular.copy(m.fetch);m.fetch=function(t,a,i){o(function(){i&&(m.state.currentPage=1);var n=l.$el.attr("grid"),o=$('div[crud-filter][grid="'+n+'"] input').scope();if(o||(o={}),a){if("main"==n&&e.location.search){var s={};if(decodeURIComponent(e.location.search).replace("?filter=","").split("&").forEach(function(e,t){var a=e.split("=");if(a[0].split("_ini").length>1){var i=a[0].replace("_ini","");s[i]||(s[i]={}),s[i].ini=decodeURIComponent(a[1])}else if(a[0].split("_fim").length>1){var i=a[0].replace("_fim","");s[i]||(s[i]={}),s[i].fim=decodeURIComponent(a[1])}else{try{a[1]=JSON.parse(a[1])}catch(n){a[1]=a[1]}"object"==typeof a[1]?s[a[0]]=a[1]:s[a[0]]=decodeURIComponent(a[1])}}),s.p&&(o.data.p=s.p,m.state.currentPage=parseInt(s.p)),s.q)o.data.q=s.q;else{o=o||{};var c=!1;Object.keys(s).forEach(function(e){if(e.split("_label").length>1)o.data[e.replace("_label","")+".label"]={id:s[e.replace("_label","")],label:s[e]};else if("object"==typeof s[e])for(var t in s[e])"ini"==t||"fim"==t?o.data[e+"_"+t]=moment(s[e][t],"DD/MM/YYYY").toDate():s[e][t].id&&s[e][t].label?o.data[e]=s[e]:(o.data[e]=o.data[e]||{},o.data[e][t]=s[e][t]);else o.data[e]=s[e];"p"!=e&&(c=!0)}),o.data.showBusca=c}o.filterData(!1)}}else if("main"==n){var d=[];if(o.objFilter&&o.objFilter.data.q&&d.push("q="+o.objFilter.data.q),o.objFilter&&o.objFilter.data.filter&&Object.keys(o.objFilter.data.filter).length>0)for(var u in o.objFilter.data.filter)if("object"==typeof o.objFilter.data.filter[u]){if(o.objFilter.data.filter[u].ini&&d.push(u+"_ini="+o.objFilter.data.filter[u].ini),o.objFilter.data.filter[u].fim&&d.push(u+"_fim="+o.objFilter.data.filter[u].fim),!o.objFilter.data.filter[u].ini&&!o.objFilter.data.filter[u].fim){var f=o.objFilter.data.filter[u];d.push(u+"="+JSON.stringify(f))}}else"p"!=u&&d.push(u+"="+o.objFilter.data.filter[u]);m.state&&m.state.currentPage&&1!=m.state.currentPage&&d.push("p="+m.state.currentPage);var p=d.join("&");r.transitionTo(r.$current.name,{filter:p},{location:!0,inherit:!0,relative:r.$current,notify:!1})}o&&o.objFilter&&o.objFilter.data.q&&(t=t||{data:{}},t.data=t.data||{},t.data.q=o.objFilter.data.q,o.objFilter.data.p&&a&&(t.data.page=o.objFilter.data.p,m.state.currentPage=parseInt(o.objFilter.data.p))),o.objFilter&&o.objFilter.data.filter&&Object.keys(o.objFilter.data.filter).length>0&&(t=t||{data:{}},t.data=t.data||{},t.data.filter=o.objFilter.data.filter,o.objFilter.data.filter.p&&a&&(t.data.page=o.objFilter.data.filter.p,m.state.currentPage=parseInt(o.objFilter.data.filter.p))),g.call(m,t)})},s(m)}l.$el=s;var u=angular.element("body").injector().get("locale");l.renderGRID=function(){d()};var f=l.$parent.$watch("headers",function(e,t){if(null!=e){var a=l.crudListSettings();if(1==a.tab)var i=l.$parent.$watch("data",function(e,t){void 0!=e.id&&(d(),i(),f())});else d(),f()}})}}}angular.module("letsAngular").directive("crudList",e),e.$inject=["$window","jQuery","Backbone","Backgrid","appSettings","fwObjectService","$timeout","$state"]}(),function(){"use strict";function e(e,t,a,i,n,l){return{templateUrl:"lets/views/crud/crud-list-table.html",scope:{settings:"="},controller:["$scope","$controller",function(e,o){o("AutoCompleteController",{$scope:e});var r=e.settings.headers;e.tab=e.settings.tab,e.filterdata={},e.tableData={total_count:0,total_entries:0,currentpage:1,data:[]},e.currentPage=1,e.perPage=r.perPage||15,"function"!=typeof r.get&&(r.get=function(e){for(var t in r.fields){var a=r.fields[t];if(a.name==e)return a}}),e.tab?(e.resource=t.all(e.settings.url),r.settings||(r.settings={add:!0,edit:!0,"delete":!0}),e.sort=r.sort):(e.resource=t.all(r.route),e.sort=r.settings.sort),e.getFilter=function(){return decodeURIComponent(i.location.search).replace("?filter=","")},e.openBuscaAvancada=function(){e.showBuscaAvancada=!e.showBuscaAvancada,e.showBuscaAvancada||e.refreshTable(!0)},e.parseRecord=function(e,t){if("boolean"==t.type)return e[t.name]?t.customOptions.statusTrueText:t.customOptions.statusFalseText;if("custom"==t.type)return"";if("date"==t.type){if(e[t.name])return void 0!==t.customOptions.monthpicker?moment(e[t.name]).format("MM/YYYY"):t.customOptions.timestamp?moment(e[t.name]).format("L LTS"):moment(e[t.name]).format("L")}else if(1==t.autocomplete){if(e[t.name]){if(!t.customOptions||void 0==t.customOptions.list)return e[t.name+".label"];for(var a=0;a0&&(e.showBuscaAvancada=!0)}}e.$emit("create:grid",e),r.isReport||e.refreshTable()},e.gopage=function(t){e.currentPage=t,e.refreshTable(!0)},e.order=function(t){!e.sort||e.sort&&e.sort.sortKey!=t?e.sort={sortKey:t,order:"asc"}:"asc"==e.sort.order?e.sort={sortKey:t,order:"desc"}:"desc"==e.sort.order&&(e.sort=void 0),e.refreshTable(!0)},e.getscope=function(){return e},e.$on("refreshGRID",function(t){e.refreshTable()})}],link:function(e,t){e.headers=e.settings.headers,e._fields=angular.copy(e.headers.fields),e.fieldsFilter=[];for(var a=0;a0){var s=a.autocomplete_dependencies;for(var c in s){var d=s[c];if(void 0==l.data[d.field]||null==l.data[d.field]||"null"==l.data[d.field]){var u=n.translate("letsfw.select_before").replace("%name%",d.label.toLocaleLowerCase()).replace("%gender%",d.gender?d.gender:"o(a)"),f=[];return f.push({id:null,label:u}),r.resolve(f),r.promise}o[d.field]=l.data[d.field]}}if(i=i.trim(),(0==i.length||1==a.customOptions.select)&&(i="[blank]"),void 0!==a.customOptions.general)l.resource.customGET("general/autocomplete/"+a.customOptions.general+"/"+i,o).then(function(e){r.resolve(e)},function(){return r.reject()});else if(void 0==a.customOptions.list){var p="autocomplete/"+a.name+"/"+i;1==a.customOptions.select?o.limit=0:o.limit=20,l.resource.customGET(p,o).then(function(e){a.customOptions.onlyList||e.unshift({id:"null",label:n.translate("letsfw.is_blank")}),e.unshift({id:null,label:"--- "+n.translate("letsfw.select")+" ---"}),r.resolve(e)},function(){return r.reject()})}else{var m=angular.copy(a.customOptions.list)||[];1==a.customOptions.select&&(a.customOptions.onlyList||m.unshift({id:"null",label:n.translate("letsfw.is_blank")}),a.customOptions.required||m.unshift({id:null,label:"--- "+n.translate("letsfw.select")+" ---"})),r.resolve(m)}return r.promise},l.autocompleteSelect=function(e,t,i){l.$emit("after-filter-autocomplete",{scope:l,name:this.field.name,value:e});var n=this.data;if(void 0==n&&(n={}),null!=e.id&&"integer"!=typeof e.id||"integer"==typeof e.id&&e.id>0)n[this.field.name]=e.id;else{if(null!=e.id)return n[this.field.name+".label"]=null,!1;n[this.field.name]=n[this.field.name+".label"]=null}this.data=n;var o=this.field;a(function(){jQuery("#"+o.name).trigger("keyup")})},l.filterData=function(e){l.objFilter=void 0;var t={};l.data.showBuscaAvancada&&(l.showBuscaAvancada=angular.copy(l.data.showBuscaAvancada),delete l.data.showBuscaAvancada),l.showBuscaAvancada||l.data.showBusca?(r.forEach(function(e,a){if("object"==typeof e.filter&&e.filter.range===!0){var i={};l.data[e.name+"_ini"]&&(i.ini=l.data[e.name+"_ini"],"date"==e.type&&(i.ini=l.getDateFormated(i.ini))),l.data[e.name+"_fim"]&&(i.fim=l.data[e.name+"_fim"],"date"==e.type&&(i.fim=l.getDateFormated(i.fim))),Object.keys(i).length>0&&(t[e.name]=i)}l.data[e.name]&&(t[e.name]=l.data[e.name],e.customOptions&&e.customOptions.telefone&&(t[e.name]=l.data[e.name].replace(/\D/g,"")),"date"==e.type&&(t[e.name]=l.getDateFormated(t[e.name])),e.autocomplete&&!e.customOptions.multiselect&&(t[e.name+"_label"]=l.data[e.name+".label"].label),e.autocomplete&&e.customOptions.multiselect&&(t[e.name]=l.data[e.name]))}),l.data.q=null,l.objFilter={data:{filter:t}}):(t.q=l.data.q,t.p=l.data.p,l.objFilter={data:t}),l.$emit("after-filter-data",l.objFilter),e&&i.$broadcast("refreshGRID",!1,!0)},l.openBuscaAvancada=function(){l.showBuscaAvancada=!l.showBuscaAvancada},l.clearBusca=function(){Object.keys(l.data).forEach(function(e){l.data[e]=null}),l.filterData(!0)},l.getDateFormated=function(e){return moment(e).format("DD/MM/YYYY")},l.startFilters(),l.$on("refresh-fields",function(e,t){l.startFilters()}),"fixed"==l.search()&&(l.showBuscaAvancada=!0,l.hideInputSearch=!0)}}}angular.module("letsAngular").directive("crudFilter",e),e.$inject=["$q","Restangular","$timeout","$rootScope","locale"]}(),function(){"use strict";function e(){return{restrict:"E",templateUrl:"lets/views/framework/breadcrumb.html",replace:!0,link:function(e,t){}}}angular.module("letsAngular").directive("crudBreadcrumb",e),e.$inject=[]}(),function(){"use strict";function e(e){this.$get=e.$get,this.state=e.state,this.setCRUDRoutes=function(e){var t={main:{enable:!0,templateUrl:"lets/views/crud/crud.html",controller:"CRUDController"},list:{enable:!0,templateUrl:"lets/views/crud/crud-list.html",controller:"CRUDController"},edit:{enable:!0,templateUrl:"lets/views/crud/crud-edit.html",controller:"CRUDEditController"},"new":{enable:!0,templateUrl:"lets/views/crud/crud-edit.html",controller:"CRUDEditController"}},a=angular.merge(t,e.options);a.main.enable&&this.state("app."+e.route,{"abstract":!0,url:"/"+e.route,templateUrl:a.main.templateUrl,controller:a.main.controller,resolve:{id:["$stateParams",function(e){return e.id}],module:function(){return e.modelName}}}),a.list.enable&&this.state("app."+e.route+".list",{url:"?filter",templateUrl:a.list.templateUrl,controller:a.list.controller}),a["new"].enable&&this.state("app."+e.route+".new",{url:"/new?filter",templateUrl:a["new"].templateUrl,controller:a["new"].controller}),a.edit.enable&&this.state("app."+e.route+".edit",{url:"/:id/edit?filter",templateUrl:a.edit.templateUrl,controller:a.edit.controller})}}e.$inject=["$stateProvider"],angular.module("letsAngular").provider("fwState",e)}(),function(){"use strict";function localeProvider(){this.locale,this.catalog={},this.onSetLocale,this.addCatalog=function(e,t){return this.catalog[e]?(console.error(e+" property already exists in the catalog."),!1):void(this.catalog[e]=t)},this.translate=function(varname){var pos=eval("this.catalog."+varname);return pos&&pos[this.locale]?pos[this.locale]:"{{__"+varname+"__}}"},this.setLocale=function(e){this.changeLocale(e),"pt-br"==this.locale?(window.ParsleyValidator.setLocale("pt-br"),moment.locale("pt-br")):"en"==this.locale?(window.ParsleyValidator.setLocale("en"),moment.locale("en")):"es"==this.locale&&(window.ParsleyValidator.setLocale("es"),moment.locale("es")),"function"==typeof this.onSetLocale&&this.onSetLocale(e)},this.getLocale=function(){return this.locale},this.changeLocale=function(e){this.locale=e},this.$get=function(){return this},this.setLocale("pt-br")}function locale(e){return function(t){return e.translate(t)}}function dateFormat(){return function(e,t){return e?moment(e).format(t):void 0}}locale.$inject=["locale"];var module=angular.module("letsAngular");module.provider("locale",localeProvider),module.filter("locale",locale),locale.inject=["locale"],module.filter("date_format",dateFormat)}(),function(){"use strict";function e(){this.$get=["$templateRequest",function(e){return new t(e)}]}function t(e){var t=this;return t.getCrudBaseTemplate=function(){return e("lets/views/crud/crud.html")},t.getCrudListTemplate=function(){return e("lets/views/crud/crud-list.html")},t.getCrudEditTemplate=function(){return e("lets/views/crud/crud-edit.html")},{getCrudBaseTemplate:t.getCrudBaseTemplate,getCrudListTemplate:t.getCrudListTemplate,getCrudEditTemplate:t.getCrudEditTemplate}}angular.module("letsAngular").provider("fwFileLoad",e)}(),function(){"use strict";var e=angular.module("letsAngular");e.config(["localeProvider",function(e){e.addCatalog("letsfw",{save:{"pt-br":"Salvar",en:"Save",es:"Guardar"},cancel:{"pt-br":"Cancelar",en:"Cancel",es:"Cancelar"},ok:{"pt-br":"Ok",en:"OK",es:"Feito"},editar:{"pt-br":"Editar",en:"Edit",es:"Editar"},excluir:{"pt-br":"Excluir",en:"Delete",es:"Eliminar"},select:{"pt-br":"Selecione",en:"Select",es:"Seleccione"},is_blank:{"pt-br":"[Em Branco]",en:"[Is blank]",es:"[En blanco]"},select_before:{"pt-br":"Selecione antes %gender% %name%",en:"Select %name% first",es:"Seleccione %name% primero"},no_record_found:{"pt-br":"Nenhum registro encontrado.",en:"No records found.",es:"No se encontraron registros."},add_new:{"pt-br":"Adicionar novo",en:"Add new",es:"Agregar nuevo"},message_delete:{"pt-br":"Deseja realmente excluir esse registro?",en:"Do you really want to delete this record?",es:"¿Desea realmente excluir este registro?"},actions:{"pt-br":"Ações",en:"Actions",es:"Acciones"},records_page:{"pt-br":"Registros na página", -en:"Records on page",es:"Registros en la página"},search:{"pt-br":"Buscar",en:"Search",es:"Buscar"},search_by:{"pt-br":"Buscar por",en:"Search by",es:"Buscar"},search_advanced:{"pt-br":"Busca Avançada",en:"Advanced search",es:"Búsqueda Avanzada"},clear_filter:{"pt-br":"Limpar Filtro",en:"Clear Filter",es:"Filtro claro"},new_record:{"pt-br":"Novo Registro",en:"New Record",es:"Nuevo Record"},main_information:{"pt-br":"Informações Principais",en:"Main Information",es:"Información Principal"},first:{"pt-br":"Primeiro",en:"First",es:"Primero"},previous:{"pt-br":"Anterior",en:"Previous",es:"Anterior"},next:{"pt-br":"Próximo",en:"Next",es:"Próximo"},last:{"pt-br":"Último",en:"Last",es:"Último"}})}])}(),function(){"use strict";function e(e){if(null!=e){"string"==typeof e&&(e=new Date(e));var t=" meses",a=moment(e),i=moment().diff(a,"months");return i?i>12&&(t=" anos",i=moment().diff(a,"years")):(t=" dias",i=moment().diff(a,"days")),i+t}}e.$inject=["birthday"],angular.module("letsAngular").filter("fwAgeMonth",e)}(),function(){"use strict";function e(e){return e.Backgrid}angular.module("letsAngular").factory("Backgrid",e),e.$inject=["$window"]}(),function(){"use strict";function e(e){return e.Backbone}angular.module("letsAngular").factory("Backbone",e),e.$inject=["$window"]}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDController",["$scope","Restangular","module","$state","$window","$rootScope","headers","swangular","ngToast",function(e,t,a,i,n,l,o,r,s){function c(){var t=angular.copy(o.get(a));e.headers=t}e.headersReady=!1,e.export_btn_is_disable=!1,c(),e.$on("refresh-headers",function(){c()}),e.resource=t.all(e.headers.route),e.$broadcast("headers-set"),e.headersReady=!0,e.getFilter=function(){return decodeURIComponent(n.location.search).replace("?filter=","")},e.goNew=function(){i.go(i.current.name.replace(".list",".new"),{filter:e.getFilter()})},e.goToList=function(){-1==i.current.name.indexOf(".list")&&i.go(i.current.name.replace(".edit",".list").replace(".new",".list"),{filter:e.getFilter()})},e.edit=function(t){i.go(i.current.name.replace(/\.list$/,".edit"),{id:t.id,page:null,filter:e.getFilter()})},e["delete"]=function(t){return e.resource.customDELETE(t.id).then(function(){l.$broadcast("refreshGRID")})},e["export"]=function(){function t(e){return e["export"]}function a(e){var t={};return t[e.name]=e.label,e.customOptions&&e.customOptions.exportColumn&&(t.exportColumn=e.customOptions.exportColumn),t}function i(e,t){if(t.length<=0)return null;if(1==t.length){if(e[0]){var a=e.map(function(e){return e[t[0]]});return a}return e[t[0]]}if(e[0]){var n=[],l=t.slice(1);return e.forEach(function(e){n.append(e[t[0]])}),i(n,l)}var n=e[t[0]],l=t.slice(1),l=t.slice(1);return i(n,l)}function n(e,t,a){e[0]&&e.forEach(function(e){if(a+=Object.keys(e)[0]+"#",e.exportColumn){var i=a+e.exportColumn[0].name;t.push({antes:i.split("#"),depois:e.exportColumn[0].label})}else{var l=Object.keys(e);if(Array.isArray(e[l[0]])){var o=e[l[0]];o.forEach(function(e){n([e],t,a)})}}a=""})}function l(e){var i=e.fields.filter(t).map(a);if(e.tabs)for(var n in e.tabs){var o=l(e.tabs[n]);if(o){var r={};r[n]=o,r.real_name=e.tabs[n].label,e.tabs[n].customOptions&&e.tabs[n].customOptions.exportColumn&&(r.exportColumn=e.tabs[n].customOptions.exportColumn),i.push(angular.copy(r))}}if(e.tabs_session)for(var n in e.tabs_session){var s=l(e.tabs_session[n]);if(s){var r={};r[n]=s,r.real_name=e.tabs_session[n].label,e.tabs_session[n].customOptions&&e.tabs_session[n].customOptions.exportColumn&&(r.exportColumn=e.tabs_session[n].customOptions.exportColumn),i.push(angular.copy(r))}}return i.length?i:void 0}function o(e,t){return t.reduce(function(e,t){if(e&&e[0]){var a=[];return e.forEach(function(e){e&&a.push(e[t])}),a}return e&&"undefined"!==e[t]?e[t]:void 0},e)}function c(e){var t={};e=e.split("&");for(var a=0;a',l+='",l+="
",b.push("m_"+r+i),h.push(a.join("#")+"#"+i)}}else i+1>0||(t.push(e.real_name),a.push(i)),l+=d(n,t,a)}),l}var u=e.getFilter();e.export_btn_is_disable=!0;var f=void 0!==e.totalPager?e.totalPager:$("tr").find("td").last().data("model").collection.state.totalRecords;if(f&&f>2e3)throw s.warning("Não é possível exportar mais que 2000 registros."),e.export_btn_is_disable=!1,"Não é possível exportar mais que 2000 registros.";var p=e.resource,m=l(e.headers),g='
',b=[],h=[];for(var v in m){var y=Object.keys(m[v])[0],w=Object.values(m[v])[0];"string"==typeof w?(g+="
",g+='',g+='",g+="
",b.push("m_"+y),h.push(y)):g+=d(m[v],[],[])}g+="
",r.swal({title:"Selecione as Colunas Desejadas",html:g,preConfirm:function(){var e=b.map(function(e){return document.getElementById(""+e).checked});return e},showCancelButton:!0}).then(function(t){if(t.value&&e.totalPager&&void 0!=e.totalPager){r.swal({html:"Por favor aguarde, estamos buscando os dados.",allowOutsideClick:!1,allowEscapeKey:!1,onOpen:function(){r.showLoading()}});var a=h.filter(function(e,a){return t.value[a]}),l=c(u);l=Object.assign({},l,{per_page:f}),p.customGET("pager",l).then(function(t){function l(){var l=t.data.map(function(e){var t={};return a.forEach(function(a){var n=a.split("#");if(1==n.length)t[a]=e[a];else if(n.length>1){n.reduce(function(t,a,l){return l===n.length-1?(t?t[a]=i(e,n):"",t):t?t[a]=t[a]?t[a]:{}:""},t)}}),t}),s=[];n(m,s,""),l.map(function(e){var t=s;t.forEach(function(t){var a=o(e,t.antes);"object"==typeof a&&(a=a.join(", ")),e[t.depois]=a}),t.forEach(function(t){t.antes[0]!=t.depois&&delete e[t.antes[0]]})}),r.close();var c=XLSX.utils.json_to_sheet(l),d=XLSX.utils.book_new();XLSX.utils.book_append_sheet(d,c,"dadosexportados");var u=moment().unix();XLSX.writeFile(d,"Exportacao_"+u+".xlsx"),e.export_btn_is_disable=!1}e.$emit("before export",t,l),e.$$listeners["before export"]||l()})}else void 0==e.totalPager||t.dismiss||r.swal({type:"info",title:"Ocorreu um erro",text:"Não é possível criar exportar os dados, pois não há registros."}),e.export_btn_is_disable=!1})},e.getscope=function(){return e}}])}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDFormModalController",["$controller","$scope","$modalInstance","headers","Restangular","$rootScope","data","fwErrorService",function(t,a,i,n,l,o,r,s){t("CRUDEditController",{$scope:a,module:e}),a.data=r||{},a.headers=n,a.resource=l.all(n.route),a.cancel=function(){i.dismiss("cancel")},a.submit=function(){this.crudForm.$valid&&i.close(a.data)},o.$on("cancel-modal",function(e,t){i.dismiss("cancel")});var c=n.parentScope;delete n.parentScope,n.modal_id&&(o.$emit("open:"+n.modal_id,a),c&&c.$emit("open:"+n.modal_id,a)),a.fetchData()}])}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDEditController",["$scope","$controller","Restangular","$stateParams","$timeout","module","$state","$rootScope","ngToast","$http","Upload","fwModalService","$window","locale",function(e,t,a,i,n,l,o,r,s,c,d,u,f,p){t("AutoCompleteController",{$scope:e}),e.data={},e.module=l,e.$http=c,e.$emit("refresh-headers"),e.datepickers={},e.loading_http_request=!1,e.datepickerToggle=function(t){void 0==e.datepickers[t]&&(e.datepickers[t]=!1),e.datepickers[t]=!e.datepickers[t]},e.fetchData=function(t,a){for(var l in e.headers.fields){var o=e.headers.fields[l];"boolean"==o.type&&void 0==e.data[o.name]&&(o.customOptions["default"]?e.data[o.name]=!0:e.data[o.name]=!1)}if(a)var r=e.resource,s=e.headers.id,c={"new":"data-new-detail",edit:"data-loaded-detail"};else var r=e.$parent.resource,s="crudGET/"+i.id,c={"new":"data-new",edit:"data-loaded"};t?r.customGET(s).then(function(t){e.parseData(t),n(function(){e.$emit(c.edit),e.$broadcast("setProgressFile")})}):n(function(){e.$emit(c["new"]),e.$broadcast("setProgressFile")},50)},e.parseData=function(t){for(var a in e.headers.fields){var i=e.headers.fields[a];if("date"==i.type&&void 0!=t[i.name]&&null!=t[i.name]){var n=new Date(t[i.name]);n.setHours(n.getHours()+n.getTimezoneOffset()/60),t[i.name]=n}i.customOptions&&void 0!=i.customOptions.list?i.customOptions.list.forEach(function(e){e.id==t[i.name]&&(t[i.name+".label"]=e)}):i.autocomplete&&t[i.name+".label"]&&"object"!=typeof t[i.name+".label"]&&(t[i.name+".label"]={id:t[i.name].id,label:t[i.name+".label"]}),"password"==i.type&&(i.notnull=!1),i.customOptions&&void 0!=i.customOptions.file&&(e.fileName=t[i.name])}e.data=t},e.headersReady&&e.fetchData(i.id),e.$on("headers-set",function(){e.fetchData(i.id)}),e.getscope=function(){return e},e._upload=function(e,t){var a=r.appSettings.API_URL,i=e.customOptions.file.container.replace(/\//g,"__");return void 0!=e.customOptions.file.url&&void 0==e.customOptions.file.container?a+=e.customOptions.file.url:void 0==e.customOptions.file.url&&void 0!=e.customOptions.file.container?a+="upload/"+i+"/upload":void 0!=e.customOptions.file.url&&void 0!=e.customOptions.file.container&&(a+="upload/"+i+"/"+e.customOptions.file.url),d.upload({url:a,data:{file:t}})},e.download=function(t,a){if(void 0!=t.customOptions.file.container)var i=t.customOptions.file.container.replace(/\//g,"__"),n=r.appSettings.API_URL+"upload/"+i+"/download/"+e.data[t.name];else var n=r.appSettings.API_URL+e.module+"/download/"+t.name+"/"+a;e._download(n,t,e.data)},e.downloadDetail=function(t,a,i,n){if(void 0!=a.customOptions.file.container)var l=r.appSettings.API_URL+"upload/"+a.customOptions.file.container+"/download/"+n[a.name];else var l=r.appSettings.API_URL+e.module+"/details/"+t+"/download/"+a.name+"/"+i;e._download(l,a,n)},e._download=function(t,a,i){this.$http({method:"GET",url:t,responseType:"arraybuffer"}).success(function(t,n,l){if(l=l(),void 0!=a.customOptions.file.container)var o=i[a.name];else var o=l["content-disposition"].split(";")[1].split("=")[1].split('"')[1];var r=l["content-type"],s=new Blob([t],{type:r});e.downloadFile(s,o)})},e.downloadFile=function(e,t){var a=document.createElement("a");try{var i=window.URL.createObjectURL(e);a.setAttribute("href",i),a.setAttribute("download",t);var n=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1});a.dispatchEvent(n)}catch(l){}},e.getFilter=function(){return decodeURIComponent(f.location.search).replace("?filter=","")},e.submit=function(){e._submit(this)},e._submit=function(t,a){function n(t){if(l.loading_http_request=!0,t)return l.loading_http_request=!1,s.warning(t.message?t.message:"Confira seu formulário"),!1;if(l.headers.tabs&&Object.keys(l.headers.tabs).forEach(function(e){l.data[e]&&delete l.data[e]}),a)if(e.data.id)var n=e.resource.customPUT(e.data,e.data.id),o="edit";else var c=e.headers.parentID||i.id,n=e.resource.customPOST(e.data,c),o="new";else if(i.id){n=e.data.put();var o="edit"}else{n=e.$parent.resource.post(e.data);var o="new"}n.then(function(t){function i(){a&&r.$broadcast("refreshGRID"),e.cancel()}l.loading_http_request=!1,e.$emit("after save",i,t,o),e.$$listeners["after save"]||i()},function(t){function a(e){for(var t in l.headers.fields){var a=l.headers.fields[t];if(a.name==e)return a.label}}var i=[];if(l.loading_http_request=!1,422==t.status)if("CANT_SAVE_MODEL"==t.data.error.code)i.push(t.data.error.message);else if(t.data.error.details){var n=t.data.error.details.codes,o={presence:"O campo %s é obrigatório",absence:"O campo %s deve ser nulo","unknown-property":"O campo %s não foi definido",length:{min:"O campo %s é muito curto",max:"O campo %s é muito longo",is:"O campo %s está com tamanho inválido"},common:{blank:"O campo %s está em branco","null":"O campo %s está nulo"},numericality:{"int":"O campo %s não é um número inteiro",number:"O campo %s não é um número"},inclusion:"O campo %s não foi incluído na lista",exclusion:"O campo %s não pode ser excluído",uniqueness:"O campo %s está repetido com o de outro registro","custom.email":"Este email não é válido"};_.each(n,function(e,t){var n=a(t);"string"==typeof e&&(e=[e]),_.each(e,function(e,t){var a=o[e].replace("%s",n);i.push(a)})})}else i.push(t.data.error.message);s.warning(i.join("
")),e.$emit("error save",t)})}var l=t,o=l.data;return _.each(l.headers.fields,function(e,a){if(e.error=void 0,o[e.name]||0==o[e.name]||e.notnull||"number"!==e.type||(o[e.name]=null),e.customOptions&&e.customOptions.file&&e.editable&&e.notnull&&!o[e.name]&&(e.error="Este campo é obrigatório.",t.crudForm.$valid=!1),"password"==e.type&&0!=e.name.indexOf("confirm")&&o["confirm_"+e.name]!=o[e.name]&&(e.error="Senha diferente da confirmação.",t.crudForm.$valid=!1),e.autocomplete&&o[e.name+".label"]&&"object"!=typeof o[e.name+".label"]&&(e.error="Campo inválido, selecione novamente.",t.crudForm.$valid=!1),"data_nascimento"==e.name){var i=o[e.name];(moment(i).isAfter(moment())||moment(i).isSame(moment(),"day"))&&(e.error="Insira uma data de nascimento válida, anterior ao dia de hoje!",t.crudForm.$valid=!1)}}),t.crudForm.$valid?(e.$emit("before save",n),void(e.$$listeners["before save"]||n())):!1},e.cancel=function(){o.go(o.current.name.replace(".edit",".list").replace(".new",".list"),{filter:e.getFilter()})},e.openPopup=function(e){e.preventDefault(),e.stopPropagation(),this.popupOpen=!0},e.buttonClick=function(t){e[t]()},e.newDetail=function(t,a,i,n){t.fixedRoute||(t.fixedRoute=t.route);var l=e.headers.route_detail?e.headers.route_detail:e.headers.route;t.route=i?n:l+t.fixedRoute,t.id=i?i:null,t.parentID=e.data.id,u.createCRUDModal(t,a,"CRUDEditDetailController",null,e)},e.deleteDetail=function(e,t){var i=a.all(e);i.customDELETE(t.id).then(function(){r.$broadcast("refreshGRID"),r.$broadcast("data-grid-updated",{type:e.split("/").pop()})},function(e){s.warning(e.data.error.message)})},e.newDetailData=function(t,a,i){if(e.data[a]=e.data[a]||[],i){var n=e.headers[t][a];n.route_detail?n.route=n.route_detail:n.route=e.headers.route+"/details/"+a,u.createCRUDModal(n,null,null,null,e).then(function(t){t["new"]=!0,e.data[a].push(t)})}else{var l={},o=e.headers[t][a].fields;for(var r in o)"boolean"!=o[r].type?l[o[r].name]=null:l[o[r].name]=!1;l["new"]=!0,e.data[a].push(l),e.$apply()}},e.editDetailData=function(t,a,i){var n=e.headers[t][a];n.route_detail?n.route=n.route_detail:n.route=e.headers.route+"/details/"+a,u.createCRUDModal(n,i,null,null,e).then(function(t){e.data[a][e.data[a].indexOf(i)]=t})},e.deleteDetailData=function(e,t){window.confirm(p.translate("letsfw.message_delete"))&&this.data[t].splice(this.data[t].indexOf(e),1)}}])}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDEditDetailController",["$scope","$controller","Restangular","headers","$rootScope","data","$modalInstance",function(t,a,i,n,l,o,r){a("CRUDEditController",{$scope:t,module:e}),t.data=o||{},t.headers=n,t.resource=i.all(n.route),t.submit=function(){t._submit(this,!0)},t.cancel=function(){r.dismiss("success")};var s=n.parentScope;delete n.parentScope,n.modal_id&&(l.$emit("open:"+n.modal_id,t),s&&s.$emit("open:"+n.modal_id,t)),t.fetchData(n.id,!0)}])}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("AutoCompleteController",["$scope","locale","$q","$timeout",function(e,t,a,i){e.autocompleteModels={},e.doafterAutoCompleteSelect={},e._autocomplete=function(i,n,l){var o=e.filterdata||e.data||{},r=[],s=a.defer();if(i.autocomplete_dependencies.length>0){var c=i.autocomplete_dependencies;for(var d in c){var u=c[d];if(void 0==o[u.field]||null==o[u.field]||"null"==o[u.field]){var f=t.translate("letsfw.select_before").replace("%name%",u.label?u.label.toLocaleLowerCase():u.field).replace("%gender%",u.gender?u.gender:"o(a)"),o=[];return o.push({id:null,label:f}),s.resolve(o),s.promise}r[u.field]="object"==typeof o[u.field]?o[u.field].id:o[u.field]}}n.length>0&&(n=encodeURIComponent(n.trim())),(0==n.length||1==i.customOptions.select)&&(n="[blank]");var p=function(e){var a=e.length>0;0==e.length&&e.unshift({id:null,label:t.translate("letsfw.no_record_found")}),1==i.customOptions.select&&a&&(i.customOptions.searchBlank&&e.unshift({id:"null",label:t.translate("letsfw.is_blank")}),i.customOptions.required||e.unshift({id:null,label:"--- "+t.translate("letsfw.select")+" ---"})),i.quickAdd===!0&&"[blank]"!=n&&e.push({id:-1,label:"Adicionar novo: "+n}),s.resolve(e)};if(void 0==i.customOptions.list){if(void 0!==i.customOptions.general)var m="general/autocomplete/"+i.customOptions.general+"/"+n;else if(l)var m="details/"+l+"/autocomplete/"+i.name+"/"+n;else var m="autocomplete/"+i.name+"/"+n;1==i.customOptions.select?r.limit=0:r.limit=20,e.resource.customGET(m,r).then(function(e){p(e)},function(){return s.reject()})}else{var g=angular.copy(i.customOptions.list)||[];p(g)}return s.promise},e._autocompleteSelect=function(t,a,n,l){this.field.error=void 0;var o=this.detail_data||this.data||{};if(null!=t.id&&"integer"!=typeof t.id||"integer"==typeof t.id&&t.id>0)o[this.field.name]=t.id;else{if(null!=t.id)return o[this.field.name+".label"]=null,!1;o[this.field.name]=o[this.field.name+".label"]=null}l?this.detail_data=o:this.data=o,e.$emit("autocomplete-select-"+this.field.name,{scope:e,value:t}),"function"==typeof e.doafterAutoCompleteSelect[this.field.name]&&e.doafterAutoCompleteSelect[this.field.name].call(this,o,t,a,n);var r=this.field;i(function(){jQuery("#"+r.name).trigger("keyup")})},e.autocompleteAdd=function(e){},e.autocomplete=function(e,t){return this._autocomplete(e,t,null)},e.autocompleteDetail=function(e,t,a){return this._autocomplete(t,a,e)},e.autocompleteSelect=function(e,t,a,i){this._autocompleteSelect(t,a,i,null)},e.autocompleteDetailSelect=function(e,t,a,i){this._autocompleteSelect(t,a,i,e)}}])}(),angular.module("letsAngular").run(["$templateCache",function(e){e.put("lets/views/framework/breadcrumb.html",''),e.put("lets/views/framework/chart.html",'

Relatório de {{key}}

'),e.put("lets/views/framework/input-detail.html",'
'),e.put("lets/views/framework/input.html",'
R$
  • {{field.error}}
  • {{field.error}}
  • A data informada é inválida.
  • {{field.error}}
  • O horário informado é inválido.
Arraste e solte o arquivo aqui.
{{f.name}}
  • {{field.error}}
  • {{field.error}}
{{column.label}}
{{data[column.name]}}
'), -e.put("lets/views/framework/paginator.html",'
  • {{\'letsfw.records_page\'|locale}}: {{pagesize}} / {{totalrecords}}
  • '),e.put("lets/views/crud/crud-detail-list.html",'
    {{field.label}}{{field.label}}{{\'letsfw.actions\'|locale}}
    {{\'letsfw.no_record_found\'|locale}}
    '),e.put("lets/views/crud/crud-edit.html",'
    '),e.put("lets/views/crud/crud-filter.html",'
    '),e.put("lets/views/crud/crud-form-input.html",'
    '),e.put("lets/views/crud/crud-form.html",'
    {{headers.label_row}} {{\'letsfw.main_information\'|locale}}
    {{headers.label_row}} {{\'letsfw.main_information\'|locale}}
    '),e.put("lets/views/crud/crud-list-table.html",'
    {{field.label}} {{field.label}}{{\'letsfw.actions\'|locale}}
    {{parseRecord(data,field)}}
    '),e.put("lets/views/crud/crud-list.html",'
    '),e.put("lets/views/crud/crud-modal.html",'
    '),e.put("lets/views/crud/crud-tab-list.html",""),e.put("lets/views/crud/crud.html",'
    ')}]); \ No newline at end of file +n.minMode="month",l="MM/yyyy"),a.find("input").attr("datepicker-popup",l),a.find("input").blur(function(){moment(this.value,l).isValid()||""===this.value?t.field.error=!1:t.field.error=!0}),t.datepickerOptions=n,e(a)(t)}},controller:["$scope",function(e){this.popupOpen=!1,this.openPopup=function(e){e.preventDefault(),e.stopPropagation(),this.popupOpen=!0}}],controllerAs:a}}angular.module("letsAngular").directive("fwDatePicker",e),e.$inject=["$compile","jQuery"]}(),function(e,t){"function"==typeof define&&define.amd?define(["angular"],t):t(angular)}(this,function(e){function t(e){return{restrict:"A",require:["ckeditor","ngModel"],controller:["$scope","$element","$attrs","$parse","$q",a],link:function(t,a,n,l){var o=l[0],r=l[1];o.ready().then(function(){["dataReady","change","blur","saveSnapshot"].forEach(function(e){o.onCKEvent(e,function(){r.$setViewValue(o.instance.getData()||"")})}),o.instance.setReadOnly(!!n.readonly),n.$observe("readonly",function(e){o.instance.setReadOnly(!!e)}),i(function(){e(n.ready)(t)})}),r.$render=function(){o.ready().then(function(){o.instance.setData(r.$viewValue||"",{noSnapshot:!0,callback:function(){o.instance.fire("updateSnapshot")}})})}}}}function a(e,t,a,n,l){var o,r=n(a.ckeditor)(e)||{},s=t[0],c=l.defer();o=s.hasAttribute("contenteditable")&&"true"==s.getAttribute("contenteditable").toLowerCase()?this.instance=CKEDITOR.inline(s,r):this.instance=CKEDITOR.replace(s,r),this.onCKEvent=function(t,a){function n(){var e=arguments;i(function(){l.apply(null,e)})}function l(){var t=arguments;e.$apply(function(){a.apply(null,t)})}return o.on(t,n),function(){o.removeListener(t,l)}},this.onCKEvent("instanceReady",function(){c.resolve(!0)}),this.ready=function(){return c.promise},e.$on("$destroy",function(){c.promise.then(function(){o.destroy(!1)})})}e.module("ckeditor",[]).directive("ckeditor",["$parse",t]);var i=window&&window.setImmediate?window.setImmediate:function(e){setTimeout(e,0)}}),function(){"use strict";function e(e,t,a){return{restrict:"E",replace:!1,scope:{crudChartSettings:"&",crudChartData:"&"},templateUrl:"lets/views/framework/chart.html",controller:["$scope",function(i){var n=i.crudChartSettings(),l=n.chart_settings,o=i.crudChartData();i.key=n.key,i.d3chartUpdate=!1;var r=t.getMinMaxValues(l.xType,l.xLabel,l.xOffset,l.yType,l.yLabel,l.yOffset,o),s={x:[r.min.x,r.max.x],y:[r.min.y,r.max.y]};i.d3chartStartDate=r.min.x,i.d3chartEndDate=r.max.x,i.d3chartConfig=e.configD3chart("line",["#092e64"],s),i.d3chartData=e.configD3chartData(n.fillArea||!1,n.key,o),i.$watch("d3chartStartDate",function(t,n){r.min.x=t,s={x:[r.min.x,r.max.x],y:[r.min.y,r.max.y]},i.d3chartConfig=e.configD3chart("line",["#092e64"],s),t!=n&&a.$broadcast("update-chart",{type:"filter"})}),i.$watch("d3chartEndDate",function(t,n){r.max.x=t,s={x:[r.min.x,r.max.x],y:[r.min.y,r.max.y]},i.d3chartConfig=e.configD3chart("line",["#092e64"],s),t!=n&&a.$broadcast("update-chart",{type:"filter"})})}],link:function(e,t,a,i,n){e.$el=t}}}angular.module("letsAngular").directive("fwChart",e),e.$inject=["fwChartService","fwComparatorService","$rootScope"]}(),function(){"use strict";function e(e,t){var a="vm";return{restrict:"A",priority:1,link:function(e,a){var i=a.find("input"),n=function(){i.val()||(i.controller("ngModel").$setViewValue(void 0),t(function(){i.controller("ngModel").$setViewValue("")}))};a.find("button").click(n),i.click(n),i.keyup(function(){""==this.value.trim()&&(i.scope().data[i.attr("name")]=null)}),a.find(".icon.fa-close").click(function(){i.scope().data[i.attr("name")]=null,i.scope().data[i.attr("name")+".label"]=null,i.scope().autocompleteSelect({id:null},{id:null}),i.val(""),i.controller("ngModel").$setViewValue("")})},controller:function(){},controllerAs:a}}angular.module("letsAngular").directive("fwAutoComplete",e),e.$inject=["$compile","$timeout"]}(),function(){"use strict";function e(e,t,a,i){var n="vm";return{restrict:"A",priority:1,link:function(e,i){var n=e;n.tableSelected=function(e,t,a){n.tableVisibily=!1;var i=e.currentTarget.firstElementChild.firstChild.data.trim();n.data[t]=a.id,n.data[t+".labelCopy"]={id:a.id,label:i},n.data[t+".label"]=i},n.loadDataAutoCompleteTable=function(e,l){var o=i.find(":input").val().split(" "),r="/^("+o[0]+")";o.splice(0,1),o.forEach(function(e){r+="(?=.*"+e+")"}),r+=".*/i";var s='{"limit": 5,"where":{"'+l+'":{"regexp":"'+r+'"}}}',c=t.appSettings.API_URL+e+"?filter="+s,d=t.appSettings.API_URL+e+"/crudGET/";a.get(c).then(function(e){n.autoCompleteTableData2=[],e.data.forEach(function(e){a.get(d+e.id).then(function(e){n.autoCompleteTableData2.push(e.data)})})})}},controller:["$scope",function(e){e.autoCompleteTableFocus=function(t){e.tableVisibily=!0},e.autoCompleteTableLostFocus=function(){setTimeout(function(){e.$apply(function(){e.tableVisibily=!1})},100)},e.updateAutoCompleteTable=function(t,a){e.loadDataAutoCompleteTable(t,a)}}],controllerAs:n}}angular.module("letsAngular").directive("fwAutoCompleteTable",e),e.$inject=["$compile","$rootScope","$http","$timeout"]}(),function(){"use strict";function e(e){return{scope:{crudTabListData:"=",crudTabListSettings:"&",parentData:"="},templateUrl:"lets/views/crud/crud-tab-list.html",link:function(e,t){setTimeout(function(){var t=e.crudTabListSettings();e.data=e.parentData,e.type=t.type,e.headers=t.headers,e.app=e.$parent.app,e.crudTabListData&&(e.extraData=e.crudTabListData)},1e3)}}}angular.module("letsAngular").directive("crudTabList",e),e.$inject=["jQuery"]}(),function(){"use strict";function e(e,t,a,i,n,l,o,r){return{scope:{crudListSettings:"&",crudListDependenciesData:"&",app:"="},controller:["$scope",function(e){e.route=null,e.$on("refreshGRID",function(t,a,i){e.pageableCRUDModel.fetch(null,a,i)}),e.$on("renderGRID",function(t){e.renderGRID()})}],link:function(l,s,c){function d(){function s(e){var a=[],n=function(){};n.prototype=new i.StringFormatter,_.extend(n.prototype,{fromRaw:function(e,t,a,i,n){return e}}),_.each(c.fields,function(e,t){if(e.viewable){var n={name:e.name,label:e.label,cell:"string",editable:!1,headers:e};if("boolean"==e.type)n.sortable=!1,n.cell=i.Cell.extend({className:"custom-situation-cell",formatter:{fromRaw:function(t,a){return t?e.customOptions.statusTrueText:e.customOptions.statusFalseText},toRaw:function(e,t){return"down"}}});else if("simplecolor"==e.type)n.sortable=!1,n.cell=i.Cell.extend({className:"custom-situation-cell",initialize:function(){i.Cell.prototype.initialize.apply(this,arguments)},render:function(){this.$el.empty();var e='';return this.$el.append(e),this.delegateEvents(),this}});else if("custom"==e.type){var l={fromRaw:e.toString,toRaw:function(e,t){return"down"}};n.sortable=!1;var o=i.Cell.extend({className:"custom-cell",formatter:l});o.initialize=function(){i.Cell.prototype.initialize.apply(this,arguments)},o.render=function(){this.$el.empty(),this.$el.data("model",this.model);var e=l.fromRaw(this.model);return this.$el.append(e),this.delegateEvents(),this},n.cell=i.Cell.extend(o)}else if("address"==e.type){var r={fromRaw:function(e,t){try{return e.city+" - "+e.state}catch(a){return""}},toRaw:function(e,t){return"down"}},s=i.Cell.extend({className:"address-cell",formatter:r});n.cell=s}else if("float"==e.type)e.customOptions&&e.customOptions.currency?n.cell=i.Cell.extend({formatter:{fromRaw:function(e,t){if(e){var e=e.toFixed(2).split(".");return e[0]="R$ "+e[0].split(/(?=(?:...)*$)/).join("."),e.join(",")}}}}):n.cell=i.NumberCell.extend({decimalSeparator:",",orderSeparator:"."});else if("date"==e.type){var c="DD/MM/YYYY",d="YYYY/M/D",u=!0;void 0!==e.customOptions.monthpicker&&(c="MM/YYYY"),e.customOptions.timestamp&&(d="YYYY/M/D HH:mm:ss.SSS",u=!1),n.cell=i.Extension.MomentCell.extend({modelFormat:d,displayLang:"pt-br",displayFormat:c,displayInUTC:u})}else if(void 0!=e.customOptions["enum"]){var f=[];for(var p in e.customOptions["enum"]){var m=e.customOptions["enum"][p];f.push([m,p])}n.cell=i.SelectCell.extend({optionValues:f})}else 1==e.autocomplete&&(e.customOptions&&void 0!=e.customOptions.list?n.cell=i.Cell.extend({className:"custom-situation-cell-select",formatter:{fromRaw:function(t,a){var i="";return e.customOptions.list.forEach(function(e){e.id==t&&(i=e.label)}),i},toRaw:function(e,t){return"down"}}}):n.name=n.name+".label");a.push(n)}});var o=i.Cell.extend({className:"text-right btn-column"+(1==c.tab?" detail":""),template:function(){var e=[];if(c.tab)if(c.settings){if(c.settings.edit){var a=t('');a.attr("data-route",c.url),e.push(a)}if(c.settings["delete"]){var i=t('');i.attr("data-route",c.url),e.push(i)}}else{var i=t('');i.attr("data-route",c.url),e.push(i)}else c.settings.edit&&e.push(t('')),c.settings["delete"]&&e.push(t(''));var n=t('
    ');return n.append(e),n},events:{},editRow:function(e){e.preventDefault()},render:function(){var e=this.template(this.model.toJSON());return this.$el.html(e),this.$el.data("model",this.model),this.$el.find("button.btn-edit").click(function(e){e.stopPropagation();var t=angular.element(this).scope();c.tab?t.$parent.edit($(this).closest("td").data("model").attributes):t.edit($(this).closest("td").data("model").attributes)}),this.$el.find("button.btn-delete").click(function(e){e.stopPropagation();var t=window.confirm(u.translate("letsfw.message_delete"));if(t){var a=angular.element(this).scope();c.tab?a.$parent["delete"]($(this).closest("td").data("model").attributes):a["delete"]($(this).closest("td").data("model").attributes)}}),this.$el.find("button.btn-delete-detail").click(function(e){e.stopPropagation();var a=window.confirm(u.translate("letsfw.message_delete"));if(a){var i=angular.element(this).scope(),n=t(this).attr("data-route");c.tab?i.$parent.deleteDetail(n,$(this).closest("td").data("model").attributes):i.deleteDetail(n,$(this).closest("td").data("model").attributes)}}),this.$el.find("button.btn-edit-detail").click(function(e){e.stopPropagation();var t=angular.element(this).scope(),a=$.parseJSON($(this).closest(".table-container").attr("tab-config")),i=$(this).closest("td").data("model").attributes,n=$(this).attr("data-route");t.newDetail(a,t.data,i.id,n)}),this.delegateEvents(),this}});(c.settings.edit||c.settings["delete"])&&a.push({name:"actions",label:u.translate("letsfw.actions"),sortable:!1,cell:o}),l.$parent.app.helpers.isScreen("xs")&&a.splice(3,1);var r=[];1==c.tab&&r.push("detail"),void 0==c.settings||c.settings.edit||r.push("cant-edit");var s=i.Row.extend({className:r.join(" ")}),d="table table-striped table-editable no-margin mb-sm";c.tableClass&&(d+=" "+c.tableClass);var f=new i.Grid({row:s,columns:a,collection:e,className:d}),p=new i.Extension.Paginator({slideScale:.25,goBackFirstOnSort:!1,collection:e,controls:{rewind:{label:'',title:"First"},back:{label:'',title:"Previous"},forward:{label:'',title:"Next"},fastForward:{label:'',title:"Last"}}});l.$el.find(".table-container").html("").append(f.render().$el).append(p.render().$el),setTimeout(function(){angular.element(p.render().$el).click(function(){window.scrollTo({top:100,behavior:"smooth"})})},0),l.$broadcast("refreshGRID",!0)}var c=l.crudListSettings();c.route=n.API_URL+c.url,l.route=c.route,i.InputCellEditor.prototype.attributes["class"]="form-control input-sm";var d=a.Model.extend({}),f={model:d,url:c.route+(c.pagerGeneral?"/pagerGeneral":"/pager"),state:{pageSize:20},mode:"server",parseRecords:function(e,t){return l.$el[0].parseRecords&&"function"==typeof l.$el[0].parseRecords?l.$el[0].parseRecords(e.data):e.data},parseState:function(e,a,i,n){return o(function(){var a=t("
      ");a.append(t("
    • ").html(u.translate("letsfw.records_page")+": "+e.total_entries+" / "+e.total_count)),l.$el.find(".table-container .backgrid-paginator ul.total-records").remove(),l.$el.find(".table-container .backgrid-paginator").append(a)}),l.$parent.totalPager=e.total_count,{totalRecords:e.total_count}}};c.filterScope&&(f.queryParams={scope:c.filterScope}),c.sort&&(f.state.sortKey=c.sort.sortKey,c.sort.order&&"desc"==c.sort.order&&(f.state.order=1));var p=a.PageableCollection.extend(f),m=new p;l.pageableCRUDModel=m;var g=angular.copy(m.fetch);m.fetch=function(t,a,i){o(function(){i&&(m.state.currentPage=1);var n=l.$el.attr("grid"),o=$('div[crud-filter][grid="'+n+'"] input').scope();if(o||(o={}),a){if("main"==n&&e.location.search){var s={};if(decodeURIComponent(e.location.search).replace("?filter=","").split("&").forEach(function(e,t){var a=e.split("=");if(a[0].split("_ini").length>1){var i=a[0].replace("_ini","");s[i]||(s[i]={}),s[i].ini=decodeURIComponent(a[1])}else if(a[0].split("_fim").length>1){var i=a[0].replace("_fim","");s[i]||(s[i]={}),s[i].fim=decodeURIComponent(a[1])}else{try{a[1]=JSON.parse(a[1])}catch(n){a[1]=a[1]}"object"==typeof a[1]?s[a[0]]=a[1]:s[a[0]]=decodeURIComponent(a[1])}}),s.p&&(o.data.p=s.p,m.state.currentPage=parseInt(s.p)),s.q)o.data.q=s.q;else{o=o||{};var c=!1;Object.keys(s).forEach(function(e){if(e.split("_label").length>1)o.data[e.replace("_label","")+".label"]={id:s[e.replace("_label","")],label:s[e]};else if("object"==typeof s[e])for(var t in s[e])"ini"==t||"fim"==t?o.data[e+"_"+t]=moment(s[e][t],"DD/MM/YYYY").toDate():s[e][t].id&&s[e][t].label?o.data[e]=s[e]:(o.data[e]=o.data[e]||{},o.data[e][t]=s[e][t]);else o.data[e]=s[e];"p"!=e&&(c=!0)}),o.data.showBusca=c}o.filterData(!1)}}else if("main"==n){var d=[];if(o.objFilter&&o.objFilter.data.q&&d.push("q="+o.objFilter.data.q),o.objFilter&&o.objFilter.data.filter&&Object.keys(o.objFilter.data.filter).length>0)for(var u in o.objFilter.data.filter)if("object"==typeof o.objFilter.data.filter[u]){if(o.objFilter.data.filter[u].ini&&d.push(u+"_ini="+o.objFilter.data.filter[u].ini),o.objFilter.data.filter[u].fim&&d.push(u+"_fim="+o.objFilter.data.filter[u].fim),!o.objFilter.data.filter[u].ini&&!o.objFilter.data.filter[u].fim){var f=o.objFilter.data.filter[u];d.push(u+"="+JSON.stringify(f))}}else"p"!=u&&d.push(u+"="+o.objFilter.data.filter[u]);m.state&&m.state.currentPage&&1!=m.state.currentPage&&d.push("p="+m.state.currentPage);var p=d.join("&");r.transitionTo(r.$current.name,{filter:p},{location:!0,inherit:!0,relative:r.$current,notify:!1})}o&&o.objFilter&&o.objFilter.data.q&&(t=t||{data:{}},t.data=t.data||{},t.data.q=o.objFilter.data.q,o.objFilter.data.p&&a&&(t.data.page=o.objFilter.data.p,m.state.currentPage=parseInt(o.objFilter.data.p))),o.objFilter&&o.objFilter.data.filter&&Object.keys(o.objFilter.data.filter).length>0&&(t=t||{data:{}},t.data=t.data||{},t.data.filter=o.objFilter.data.filter,o.objFilter.data.filter.p&&a&&(t.data.page=o.objFilter.data.filter.p,m.state.currentPage=parseInt(o.objFilter.data.filter.p))),g.call(m,t)})},s(m)}l.$el=s;var u=angular.element("body").injector().get("locale");l.renderGRID=function(){d()};var f=l.$parent.$watch("headers",function(e,t){if(null!=e){var a=l.crudListSettings();if(1==a.tab)var i=l.$parent.$watch("data",function(e,t){void 0!=e.id&&(d(),i(),f())});else d(),f()}})}}}angular.module("letsAngular").directive("crudList",e),e.$inject=["$window","jQuery","Backbone","Backgrid","appSettings","fwObjectService","$timeout","$state"]}(),function(){"use strict";function e(e,t,a,i,n,l){return{templateUrl:"lets/views/crud/crud-list-table.html",scope:{settings:"="},controller:["$scope","$controller",function(e,o){o("AutoCompleteController",{$scope:e});var r=e.settings.headers;e.tab=e.settings.tab,e.filterdata={},e.tableData={total_count:0,total_entries:0,currentpage:1,data:[]},e.currentPage=1,e.perPage=r.perPage||15,"function"!=typeof r.get&&(r.get=function(e){for(var t in r.fields){var a=r.fields[t];if(a.name==e)return a}}),e.tab?(e.resource=t.all(e.settings.url),r.settings||(r.settings={add:!0,edit:!0,"delete":!0}),e.sort=r.sort):(e.resource=t.all(r.route),e.sort=r.settings.sort),e.getFilter=function(){return decodeURIComponent(i.location.search).replace("?filter=","")},e.openBuscaAvancada=function(){e.showBuscaAvancada=!e.showBuscaAvancada,e.showBuscaAvancada||e.refreshTable(!0)},e.parseRecord=function(e,t){if("boolean"==t.type)return e[t.name]?t.customOptions.statusTrueText:t.customOptions.statusFalseText;if("custom"==t.type)return"";if("date"==t.type){if(e[t.name])return void 0!==t.customOptions.monthpicker?moment(e[t.name]).format("MM/YYYY"):t.customOptions.timestamp?moment(e[t.name]).format("L LTS"):moment(e[t.name]).format("L")}else if(1==t.autocomplete){if(e[t.name]){if(!t.customOptions||void 0==t.customOptions.list)return e[t.name+".label"];for(var a=0;a0&&(e.showBuscaAvancada=!0)}}e.$emit("create:grid",e),r.isReport||e.refreshTable()},e.gopage=function(t){e.currentPage=t,e.refreshTable(!0)},e.order=function(t){!e.sort||e.sort&&e.sort.sortKey!=t?e.sort={sortKey:t,order:"asc"}:"asc"==e.sort.order?e.sort={sortKey:t,order:"desc"}:"desc"==e.sort.order&&(e.sort=void 0),e.refreshTable(!0)},e.getscope=function(){return e},e.$on("refreshGRID",function(t){e.refreshTable()})}],link:function(e,t){e.headers=e.settings.headers,e._fields=angular.copy(e.headers.fields),e.fieldsFilter=[];for(var a=0;a0){var s=a.autocomplete_dependencies;for(var c in s){var d=s[c];if(void 0==l.data[d.field]||null==l.data[d.field]||"null"==l.data[d.field]){var u=n.translate("letsfw.select_before").replace("%name%",d.label.toLocaleLowerCase()).replace("%gender%",d.gender?d.gender:"o(a)"),f=[];return f.push({id:null,label:u}),r.resolve(f),r.promise}o[d.field]=l.data[d.field]}}if(i=i.trim(),(0==i.length||1==a.customOptions.select)&&(i="[blank]"),void 0!==a.customOptions.general)l.resource.customGET("general/autocomplete/"+a.customOptions.general+"/"+i,o).then(function(e){r.resolve(e)},function(){return r.reject()});else if(void 0==a.customOptions.list){var p="autocomplete/"+a.name+"/"+i;1==a.customOptions.select?o.limit=0:o.limit=20,l.resource.customGET(p,o).then(function(e){a.customOptions.onlyList||e.unshift({id:"null",label:n.translate("letsfw.is_blank")}),e.unshift({id:null,label:"--- "+n.translate("letsfw.select")+" ---"}),r.resolve(e)},function(){return r.reject()})}else{var m=angular.copy(a.customOptions.list)||[];1==a.customOptions.select&&(a.customOptions.onlyList||m.unshift({id:"null",label:n.translate("letsfw.is_blank")}),a.customOptions.required||m.unshift({id:null,label:"--- "+n.translate("letsfw.select")+" ---"})),r.resolve(m)}return r.promise},l.autocompleteSelect=function(e,t,i){l.$emit("after-filter-autocomplete",{scope:l,name:this.field.name,value:e});var n=this.data;if(void 0==n&&(n={}),null!=e.id&&"integer"!=typeof e.id||"integer"==typeof e.id&&e.id>0)n[this.field.name]=e.id;else{if(null!=e.id)return n[this.field.name+".label"]=null,!1;n[this.field.name]=n[this.field.name+".label"]=null}this.data=n;var o=this.field;a(function(){jQuery("#"+o.name).trigger("keyup")})},l.filterData=function(e){l.objFilter=void 0;var t={};l.data.showBuscaAvancada&&(l.showBuscaAvancada=angular.copy(l.data.showBuscaAvancada),delete l.data.showBuscaAvancada),l.showBuscaAvancada||l.data.showBusca?(r.forEach(function(e,a){if("object"==typeof e.filter&&e.filter.range===!0){var i={};l.data[e.name+"_ini"]&&(i.ini=l.data[e.name+"_ini"],"date"==e.type&&(i.ini=l.getDateFormated(i.ini))),l.data[e.name+"_fim"]&&(i.fim=l.data[e.name+"_fim"],"date"==e.type&&(i.fim=l.getDateFormated(i.fim))),Object.keys(i).length>0&&(t[e.name]=i)}l.data[e.name]&&(t[e.name]=l.data[e.name],e.customOptions&&e.customOptions.telefone&&(t[e.name]=l.data[e.name].replace(/\D/g,"")),"date"==e.type&&(t[e.name]=l.getDateFormated(t[e.name])),e.autocomplete&&!e.customOptions.multiselect&&(t[e.name+"_label"]=l.data[e.name+".label"].label),e.autocomplete&&e.customOptions.multiselect&&(t[e.name]=l.data[e.name]))}),l.data.q=null,l.objFilter={data:{filter:t}}):(t.q=l.data.q,t.p=l.data.p,l.objFilter={data:t}),l.$emit("after-filter-data",l.objFilter),e&&i.$broadcast("refreshGRID",!1,!0)},l.openBuscaAvancada=function(){l.showBuscaAvancada=!l.showBuscaAvancada},l.clearBusca=function(){Object.keys(l.data).forEach(function(e){l.data[e]=null}),l.filterData(!0)},l.getDateFormated=function(e){return moment(e).format("DD/MM/YYYY")},l.startFilters(),l.$on("refresh-fields",function(e,t){l.startFilters()}),"fixed"==l.search()&&(l.showBuscaAvancada=!0,l.hideInputSearch=!0)}}}angular.module("letsAngular").directive("crudFilter",e),e.$inject=["$q","Restangular","$timeout","$rootScope","locale"]}(),function(){"use strict";function e(){return{restrict:"E",templateUrl:"lets/views/framework/breadcrumb.html",replace:!0,link:function(e,t){}}}angular.module("letsAngular").directive("crudBreadcrumb",e),e.$inject=[]}(),function(){"use strict";function e(e){this.$get=e.$get,this.state=e.state,this.setCRUDRoutes=function(e){var t={main:{enable:!0,templateUrl:"lets/views/crud/crud.html",controller:"CRUDController"},list:{enable:!0,templateUrl:"lets/views/crud/crud-list.html",controller:"CRUDController"},edit:{enable:!0,templateUrl:"lets/views/crud/crud-edit.html",controller:"CRUDEditController"},"new":{enable:!0,templateUrl:"lets/views/crud/crud-edit.html",controller:"CRUDEditController"}},a=angular.merge(t,e.options);a.main.enable&&this.state("app."+e.route,{"abstract":!0,url:"/"+e.route,templateUrl:a.main.templateUrl,controller:a.main.controller,resolve:{id:["$stateParams",function(e){return e.id}],module:function(){return e.modelName}}}),a.list.enable&&this.state("app."+e.route+".list",{url:"?filter",templateUrl:a.list.templateUrl,controller:a.list.controller}),a["new"].enable&&this.state("app."+e.route+".new",{url:"/new?filter",templateUrl:a["new"].templateUrl,controller:a["new"].controller}),a.edit.enable&&this.state("app."+e.route+".edit",{url:"/:id/edit?filter",templateUrl:a.edit.templateUrl,controller:a.edit.controller})}}e.$inject=["$stateProvider"],angular.module("letsAngular").provider("fwState",e)}(),function(){"use strict";function localeProvider(){this.locale,this.catalog={},this.onSetLocale,this.addCatalog=function(e,t){return this.catalog[e]?(console.error(e+" property already exists in the catalog."),!1):void(this.catalog[e]=t)},this.translate=function(varname){var pos=eval("this.catalog."+varname);return pos&&pos[this.locale]?pos[this.locale]:"{{__"+varname+"__}}"},this.setLocale=function(e){this.changeLocale(e),"pt-br"==this.locale?(window.ParsleyValidator.setLocale("pt-br"),moment.locale("pt-br")):"en"==this.locale?(window.ParsleyValidator.setLocale("en"),moment.locale("en")):"es"==this.locale&&(window.ParsleyValidator.setLocale("es"),moment.locale("es")),"function"==typeof this.onSetLocale&&this.onSetLocale(e)},this.getLocale=function(){return this.locale},this.changeLocale=function(e){this.locale=e},this.$get=function(){return this},this.setLocale("pt-br")}function locale(e){return function(t){return e.translate(t)}}function dateFormat(){return function(e,t){return e?moment(e).format(t):void 0}}locale.$inject=["locale"];var module=angular.module("letsAngular");module.provider("locale",localeProvider),module.filter("locale",locale),locale.inject=["locale"],module.filter("date_format",dateFormat)}(),function(){"use strict";function e(){this.$get=["$templateRequest",function(e){return new t(e)}]}function t(e){var t=this;return t.getCrudBaseTemplate=function(){return e("lets/views/crud/crud.html")},t.getCrudListTemplate=function(){return e("lets/views/crud/crud-list.html")},t.getCrudEditTemplate=function(){return e("lets/views/crud/crud-edit.html")},{getCrudBaseTemplate:t.getCrudBaseTemplate,getCrudListTemplate:t.getCrudListTemplate,getCrudEditTemplate:t.getCrudEditTemplate}}angular.module("letsAngular").provider("fwFileLoad",e)}(),function(){"use strict";var e=angular.module("letsAngular");e.config(["localeProvider",function(e){e.addCatalog("letsfw",{save:{"pt-br":"Salvar",en:"Save",es:"Guardar"},cancel:{"pt-br":"Cancelar",en:"Cancel",es:"Cancelar"},ok:{"pt-br":"Ok",en:"OK",es:"Feito"},editar:{"pt-br":"Editar",en:"Edit",es:"Editar"},excluir:{"pt-br":"Excluir",en:"Delete",es:"Eliminar"},select:{"pt-br":"Selecione",en:"Select",es:"Seleccione"},is_blank:{"pt-br":"[Em Branco]",en:"[Is blank]",es:"[En blanco]"},select_before:{"pt-br":"Selecione antes %gender% %name%",en:"Select %name% first",es:"Seleccione %name% primero"},no_record_found:{"pt-br":"Nenhum registro encontrado.",en:"No records found.",es:"No se encontraron registros."},add_new:{"pt-br":"Adicionar novo",en:"Add new",es:"Agregar nuevo"},message_delete:{"pt-br":"Deseja realmente excluir esse registro?",en:"Do you really want to delete this record?",es:"¿Desea realmente excluir este registro?"},actions:{"pt-br":"Ações",en:"Actions",es:"Acciones" +},records_page:{"pt-br":"Registros na página",en:"Records on page",es:"Registros en la página"},search:{"pt-br":"Buscar",en:"Search",es:"Buscar"},search_by:{"pt-br":"Buscar por",en:"Search by",es:"Buscar"},search_advanced:{"pt-br":"Busca Avançada",en:"Advanced search",es:"Búsqueda Avanzada"},clear_filter:{"pt-br":"Limpar Filtro",en:"Clear Filter",es:"Filtro claro"},new_record:{"pt-br":"Novo Registro",en:"New Record",es:"Nuevo Record"},main_information:{"pt-br":"Informações Principais",en:"Main Information",es:"Información Principal"},first:{"pt-br":"Primeiro",en:"First",es:"Primero"},previous:{"pt-br":"Anterior",en:"Previous",es:"Anterior"},next:{"pt-br":"Próximo",en:"Next",es:"Próximo"},last:{"pt-br":"Último",en:"Last",es:"Último"}})}])}(),function(){"use strict";function e(e){if(null!=e){"string"==typeof e&&(e=new Date(e));var t=" meses",a=moment(e),i=moment().diff(a,"months");return i?i>12&&(t=" anos",i=moment().diff(a,"years")):(t=" dias",i=moment().diff(a,"days")),i+t}}e.$inject=["birthday"],angular.module("letsAngular").filter("fwAgeMonth",e)}(),function(){"use strict";function e(e){return e.Backgrid}angular.module("letsAngular").factory("Backgrid",e),e.$inject=["$window"]}(),function(){"use strict";function e(e){return e.Backbone}angular.module("letsAngular").factory("Backbone",e),e.$inject=["$window"]}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDController",["$scope","Restangular","module","$state","$window","$rootScope","headers","swangular","ngToast",function(e,t,a,i,n,l,o,r,s){function c(){var t=angular.copy(o.get(a));e.headers=t}e.headersReady=!1,e.export_btn_is_disable=!1,c(),e.$on("refresh-headers",function(){c()}),e.resource=t.all(e.headers.route),e.$broadcast("headers-set"),e.headersReady=!0,e.getFilter=function(){return decodeURIComponent(n.location.search).replace("?filter=","")},e.goNew=function(){i.go(i.current.name.replace(".list",".new"),{filter:e.getFilter()})},e.goToList=function(){-1==i.current.name.indexOf(".list")&&i.go(i.current.name.replace(".edit",".list").replace(".new",".list"),{filter:e.getFilter()})},e.edit=function(t){i.go(i.current.name.replace(/\.list$/,".edit"),{id:t.id,page:null,filter:e.getFilter()})},e["delete"]=function(t){return e.resource.customDELETE(t.id).then(function(){l.$broadcast("refreshGRID")})},e["export"]=function(){function t(e){return e["export"]}function a(e){var t={};return t[e.name]=e.label,e.customOptions&&e.customOptions.exportColumn&&(t.exportColumn=e.customOptions.exportColumn),t}function i(e,t){if(t.length<=0)return null;if(1==t.length){if(e[0]){var a=e.map(function(e){return e[t[0]]});return a}return e[t[0]]}if(e[0]){var n=[],l=t.slice(1);return e.forEach(function(e){n.append(e[t[0]])}),i(n,l)}var n=e[t[0]],l=t.slice(1),l=t.slice(1);return i(n,l)}function n(e,t,a){e[0]&&e.forEach(function(e){if(a+=Object.keys(e)[0]+"#",e.exportColumn){var i=a+e.exportColumn[0].name;t.push({antes:i.split("#"),depois:e.exportColumn[0].label})}else{var l=Object.keys(e);if(Array.isArray(e[l[0]])){var o=e[l[0]];o.forEach(function(e){n([e],t,a)})}}a=""})}function l(e){var i=e.fields.filter(t).map(a);if(e.tabs)for(var n in e.tabs){var o=l(e.tabs[n]);if(o){var r={};r[n]=o,r.real_name=e.tabs[n].label,e.tabs[n].customOptions&&e.tabs[n].customOptions.exportColumn&&(r.exportColumn=e.tabs[n].customOptions.exportColumn),i.push(angular.copy(r))}}if(e.tabs_session)for(var n in e.tabs_session){var s=l(e.tabs_session[n]);if(s){var r={};r[n]=s,r.real_name=e.tabs_session[n].label,e.tabs_session[n].customOptions&&e.tabs_session[n].customOptions.exportColumn&&(r.exportColumn=e.tabs_session[n].customOptions.exportColumn),i.push(angular.copy(r))}}return i.length?i:void 0}function o(e,t){return t.reduce(function(e,t){if(e&&e[0]){var a=[];return e.forEach(function(e){e&&a.push(e[t])}),a}return e&&"undefined"!==e[t]?e[t]:void 0},e)}function c(e){var t={};e=e.split("&");for(var a=0;a',l+='",l+="
    ",b.push("m_"+r+i),h.push(a.join("#")+"#"+i)}}else i+1>0||(t.push(e.real_name),a.push(i)),l+=d(n,t,a)}),l}var u=e.getFilter();e.export_btn_is_disable=!0;var f=void 0!==e.totalPager?e.totalPager:$("tr").find("td").last().data("model").collection.state.totalRecords;if(f&&f>2e3)throw s.warning("Não é possível exportar mais que 2000 registros."),e.export_btn_is_disable=!1,"Não é possível exportar mais que 2000 registros.";var p=e.resource,m=l(e.headers),g='
    ',b=[],h=[];for(var v in m){var y=Object.keys(m[v])[0],w=Object.values(m[v])[0];"string"==typeof w?(g+="
    ",g+='',g+='",g+="
    ",b.push("m_"+y),h.push(y)):g+=d(m[v],[],[])}g+="
    ",r.swal({title:"Selecione as Colunas Desejadas",html:g,preConfirm:function(){var e=b.map(function(e){return document.getElementById(""+e).checked});return e},showCancelButton:!0}).then(function(t){if(t.value&&e.totalPager&&void 0!=e.totalPager){r.swal({html:"Por favor aguarde, estamos buscando os dados.",allowOutsideClick:!1,allowEscapeKey:!1,onOpen:function(){r.showLoading()}});var a=h.filter(function(e,a){return t.value[a]}),l=c(u);l=Object.assign({},l,{per_page:f}),p.customGET("pager",l).then(function(t){function l(){var l=t.data.map(function(e){var t={};return a.forEach(function(a){var n=a.split("#");if(1==n.length)t[a]=e[a];else if(n.length>1){n.reduce(function(t,a,l){return l===n.length-1?(t?t[a]=i(e,n):"",t):t?t[a]=t[a]?t[a]:{}:""},t)}}),t}),s=[];n(m,s,""),l.map(function(e){var t=s;t.forEach(function(t){var a=o(e,t.antes);"object"==typeof a&&(a=a.join(", ")),e[t.depois]=a}),t.forEach(function(t){t.antes[0]!=t.depois&&delete e[t.antes[0]]})}),r.close();var c=XLSX.utils.json_to_sheet(l),d=XLSX.utils.book_new();XLSX.utils.book_append_sheet(d,c,"dadosexportados");var u=moment().unix();XLSX.writeFile(d,"Exportacao_"+u+".xlsx"),e.export_btn_is_disable=!1}e.$emit("before export",t,l),e.$$listeners["before export"]||l()})}else void 0==e.totalPager||t.dismiss||r.swal({type:"info",title:"Ocorreu um erro",text:"Não é possível criar exportar os dados, pois não há registros."}),e.export_btn_is_disable=!1})},e.getscope=function(){return e}}])}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDFormModalController",["$controller","$scope","$modalInstance","headers","Restangular","$rootScope","data","fwErrorService",function(t,a,i,n,l,o,r,s){t("CRUDEditController",{$scope:a,module:e}),a.data=r||{},a.headers=n,a.resource=l.all(n.route),a.cancel=function(){i.dismiss("cancel")},a.submit=function(){this.crudForm.$valid&&i.close(a.data)},o.$on("cancel-modal",function(e,t){i.dismiss("cancel")});var c=n.parentScope;delete n.parentScope,n.modal_id&&(o.$emit("open:"+n.modal_id,a),c&&c.$emit("open:"+n.modal_id,a)),a.fetchData()}])}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDEditController",["$scope","$controller","Restangular","$stateParams","$timeout","module","$state","$rootScope","ngToast","$http","Upload","fwModalService","$window","locale",function(e,t,a,i,n,l,o,r,s,c,d,u,f,p){t("AutoCompleteController",{$scope:e}),e.data={},e.module=l,e.$http=c,e.$emit("refresh-headers"),e.datepickers={},e.loading_http_request=!1,e.datepickerToggle=function(t){void 0==e.datepickers[t]&&(e.datepickers[t]=!1),e.datepickers[t]=!e.datepickers[t]},e.fetchData=function(t,a){for(var l in e.headers.fields){var o=e.headers.fields[l];"boolean"==o.type&&void 0==e.data[o.name]&&(o.customOptions["default"]?e.data[o.name]=!0:e.data[o.name]=!1)}if(a)var r=e.resource,s=e.headers.id,c={"new":"data-new-detail",edit:"data-loaded-detail"};else var r=e.$parent.resource,s="crudGET/"+i.id,c={"new":"data-new",edit:"data-loaded"};t?r.customGET(s).then(function(t){e.parseData(t),n(function(){e.$emit(c.edit),e.$broadcast("setProgressFile")})}):n(function(){e.$emit(c["new"]),e.$broadcast("setProgressFile")},50)},e.parseData=function(t){for(var a in e.headers.fields){var i=e.headers.fields[a];if("date"==i.type&&void 0!=t[i.name]&&null!=t[i.name]){var n=new Date(t[i.name]);n.setHours(n.getHours()+n.getTimezoneOffset()/60),t[i.name]=n}i.customOptions&&void 0!=i.customOptions.list?i.customOptions.list.forEach(function(e){e.id==t[i.name]&&(t[i.name+".label"]=e)}):i.autocomplete&&t[i.name+".label"]&&"object"!=typeof t[i.name+".label"]&&(t[i.name+".label"]={id:t[i.name].id,label:t[i.name+".label"]}),"password"==i.type&&(i.notnull=!1),i.customOptions&&void 0!=i.customOptions.file&&(e.fileName=t[i.name])}e.data=t},e.headersReady&&e.fetchData(i.id),e.$on("headers-set",function(){e.fetchData(i.id)}),e.getscope=function(){return e},e._upload=function(e,t){var a=r.appSettings.API_URL,i=e.customOptions.file.container.replace(/\//g,"__");return void 0!=e.customOptions.file.url&&void 0==e.customOptions.file.container?a+=e.customOptions.file.url:void 0==e.customOptions.file.url&&void 0!=e.customOptions.file.container?a+="upload/"+i+"/upload":void 0!=e.customOptions.file.url&&void 0!=e.customOptions.file.container&&(a+="upload/"+i+"/"+e.customOptions.file.url),d.upload({url:a,data:{file:t}})},e.download=function(t,a){if(void 0!=t.customOptions.file.container)var i=t.customOptions.file.container.replace(/\//g,"__"),n=r.appSettings.API_URL+"upload/"+i+"/download/"+e.data[t.name];else var n=r.appSettings.API_URL+e.module+"/download/"+t.name+"/"+a;e._download(n,t,e.data)},e.downloadDetail=function(t,a,i,n){if(void 0!=a.customOptions.file.container)var l=r.appSettings.API_URL+"upload/"+a.customOptions.file.container+"/download/"+n[a.name];else var l=r.appSettings.API_URL+e.module+"/details/"+t+"/download/"+a.name+"/"+i;e._download(l,a,n)},e._download=function(t,a,i){this.$http({method:"GET",url:t,responseType:"arraybuffer"}).success(function(t,n,l){if(l=l(),void 0!=a.customOptions.file.container)var o=i[a.name];else var o=l["content-disposition"].split(";")[1].split("=")[1].split('"')[1];var r=l["content-type"],s=new Blob([t],{type:r});e.downloadFile(s,o)})},e.downloadFile=function(e,t){var a=document.createElement("a");try{var i=window.URL.createObjectURL(e);a.setAttribute("href",i),a.setAttribute("download",t);var n=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1});a.dispatchEvent(n)}catch(l){}},e.getFilter=function(){return decodeURIComponent(f.location.search).replace("?filter=","")},e.submit=function(){e._submit(this)},e._submit=function(t,a){function n(t){if(l.loading_http_request=!0,t)return l.loading_http_request=!1,s.warning(t.message?t.message:"Confira seu formulário"),!1;if(l.headers.tabs&&Object.keys(l.headers.tabs).forEach(function(e){l.data[e]&&delete l.data[e]}),a)if(e.data.id)var n=e.resource.customPUT(e.data,e.data.id),o="edit";else var c=e.headers.parentID||i.id,n=e.resource.customPOST(e.data,c),o="new";else if(i.id){n=e.data.put();var o="edit"}else{n=e.$parent.resource.post(e.data);var o="new"}n.then(function(t){function i(){a&&r.$broadcast("refreshGRID"),e.cancel()}l.loading_http_request=!1,e.$emit("after save",i,t,o),e.$$listeners["after save"]||i()},function(t){function a(e){for(var t in l.headers.fields){var a=l.headers.fields[t];if(a.name==e)return a.label}}var i=[];if(l.loading_http_request=!1,422==t.status)if("CANT_SAVE_MODEL"==t.data.error.code)i.push(t.data.error.message);else if(t.data.error.details){var n=t.data.error.details.codes,o={presence:"O campo %s é obrigatório",absence:"O campo %s deve ser nulo","unknown-property":"O campo %s não foi definido",length:{min:"O campo %s é muito curto",max:"O campo %s é muito longo",is:"O campo %s está com tamanho inválido"},common:{blank:"O campo %s está em branco","null":"O campo %s está nulo"},numericality:{"int":"O campo %s não é um número inteiro",number:"O campo %s não é um número"},inclusion:"O campo %s não foi incluído na lista",exclusion:"O campo %s não pode ser excluído",uniqueness:"O campo %s está repetido com o de outro registro","custom.email":"Este email não é válido"};_.each(n,function(e,t){var n=a(t);"string"==typeof e&&(e=[e]),_.each(e,function(e,t){var a=o[e].replace("%s",n);i.push(a)})})}else i.push(t.data.error.message);s.warning(i.join("
    ")),e.$emit("error save",t)})}var l=t,o=l.data;return _.each(l.headers.fields,function(e,a){if(e.error=void 0,o[e.name]||0==o[e.name]||e.notnull||"number"!==e.type||(o[e.name]=null),e.customOptions&&e.customOptions.file&&e.editable&&e.notnull&&!o[e.name]&&(e.error="Este campo é obrigatório.",t.crudForm.$valid=!1),"password"==e.type&&0!=e.name.indexOf("confirm")&&o["confirm_"+e.name]!=o[e.name]&&(e.error="Senha diferente da confirmação.",t.crudForm.$valid=!1),e.autocomplete&&o[e.name+".label"]&&"object"!=typeof o[e.name+".label"]&&(e.error="Campo inválido, selecione novamente.",t.crudForm.$valid=!1),"data_nascimento"==e.name){var i=o[e.name];(moment(i).isAfter(moment())||moment(i).isSame(moment(),"day"))&&(e.error="Insira uma data de nascimento válida, anterior ao dia de hoje!",t.crudForm.$valid=!1)}}),t.crudForm.$valid?(e.$emit("before save",n),void(e.$$listeners["before save"]||n())):!1},e.cancel=function(){o.go(o.current.name.replace(".edit",".list").replace(".new",".list"),{filter:e.getFilter()})},e.openPopup=function(e){e.preventDefault(),e.stopPropagation(),this.popupOpen=!0},e.buttonClick=function(t){e[t]()},e.newDetail=function(t,a,i,n){t.fixedRoute||(t.fixedRoute=t.route);var l=e.headers.route_detail?e.headers.route_detail:e.headers.route;t.route=i?n:l+t.fixedRoute,t.id=i?i:null,t.parentID=e.data.id,u.createCRUDModal(t,a,"CRUDEditDetailController",null,e)},e.deleteDetail=function(e,t){var i=a.all(e);i.customDELETE(t.id).then(function(){r.$broadcast("refreshGRID"),r.$broadcast("data-grid-updated",{type:e.split("/").pop()})},function(e){s.warning(e.data.error.message)})},e.newDetailData=function(t,a,i){if(e.data[a]=e.data[a]||[],i){var n=e.headers[t][a];n.route_detail?n.route=n.route_detail:n.route=e.headers.route+"/details/"+a,u.createCRUDModal(n,null,null,null,e).then(function(t){t["new"]=!0,e.data[a].push(t)})}else{var l={},o=e.headers[t][a].fields;for(var r in o)"boolean"!=o[r].type?l[o[r].name]=null:l[o[r].name]=!1;l["new"]=!0,e.data[a].push(l),e.$apply()}},e.editDetailData=function(t,a,i){var n=e.headers[t][a];n.route_detail?n.route=n.route_detail:n.route=e.headers.route+"/details/"+a,u.createCRUDModal(n,i,null,null,e).then(function(t){e.data[a][e.data[a].indexOf(i)]=t})},e.deleteDetailData=function(e,t){window.confirm(p.translate("letsfw.message_delete"))&&this.data[t].splice(this.data[t].indexOf(e),1)}}])}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDEditDetailController",["$scope","$controller","Restangular","headers","$rootScope","data","$modalInstance",function(t,a,i,n,l,o,r){a("CRUDEditController",{$scope:t,module:e}),t.data=o||{},t.headers=n,t.resource=i.all(n.route),t.submit=function(){t._submit(this,!0)},t.cancel=function(){r.dismiss("success")};var s=n.parentScope;delete n.parentScope,n.modal_id&&(l.$emit("open:"+n.modal_id,t),s&&s.$emit("open:"+n.modal_id,t)),t.fetchData(n.id,!0)}])}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("AutoCompleteController",["$scope","locale","$q","$timeout",function(e,t,a,i){e.autocompleteModels={},e.doafterAutoCompleteSelect={},e._autocomplete=function(i,n,l){var o=e.filterdata||e.data||{},r=[],s=a.defer();if(i.autocomplete_dependencies.length>0){var c=i.autocomplete_dependencies;for(var d in c){var u=c[d];if(void 0==o[u.field]||null==o[u.field]||"null"==o[u.field]){var f=t.translate("letsfw.select_before").replace("%name%",u.label?u.label.toLocaleLowerCase():u.field).replace("%gender%",u.gender?u.gender:"o(a)"),o=[];return o.push({id:null,label:f}),s.resolve(o),s.promise}r[u.field]="object"==typeof o[u.field]?o[u.field].id:o[u.field]}}n.length>0&&(n=encodeURIComponent(n.trim())),(0==n.length||1==i.customOptions.select)&&(n="[blank]");var p=function(e){var a=e.length>0;0==e.length&&e.unshift({id:null,label:t.translate("letsfw.no_record_found")}),1==i.customOptions.select&&a&&(i.customOptions.searchBlank&&e.unshift({id:"null",label:t.translate("letsfw.is_blank")}),i.customOptions.required||e.unshift({id:null,label:"--- "+t.translate("letsfw.select")+" ---"})),i.quickAdd===!0&&"[blank]"!=n&&e.push({id:-1,label:"Adicionar novo: "+n}),s.resolve(e)};if(void 0==i.customOptions.list){if(void 0!==i.customOptions.general)var m="general/autocomplete/"+i.customOptions.general+"/"+n;else if(l)var m="details/"+l+"/autocomplete/"+i.name+"/"+n;else var m="autocomplete/"+i.name+"/"+n;1==i.customOptions.select?r.limit=0:r.limit=20,e.resource.customGET(m,r).then(function(e){p(e)},function(){return s.reject()})}else{var g=angular.copy(i.customOptions.list)||[];p(g)}return s.promise},e._autocompleteSelect=function(t,a,n,l){this.field.error=void 0;var o=this.detail_data||this.data||{};if(null!=t.id&&"integer"!=typeof t.id||"integer"==typeof t.id&&t.id>0)o[this.field.name]=t.id;else{if(null!=t.id)return o[this.field.name+".label"]=null,!1;o[this.field.name]=o[this.field.name+".label"]=null}l?this.detail_data=o:this.data=o,e.$emit("autocomplete-select-"+this.field.name,{scope:e,value:t}),"function"==typeof e.doafterAutoCompleteSelect[this.field.name]&&e.doafterAutoCompleteSelect[this.field.name].call(this,o,t,a,n);var r=this.field;i(function(){jQuery("#"+r.name).trigger("keyup")})},e.autocompleteAdd=function(e){},e.autocomplete=function(e,t){return this._autocomplete(e,t,null)},e.autocompleteDetail=function(e,t,a){return this._autocomplete(t,a,e)},e.autocompleteSelect=function(e,t,a,i){this._autocompleteSelect(t,a,i,null)},e.autocompleteDetailSelect=function(e,t,a,i){this._autocompleteSelect(t,a,i,e)}}])}(),angular.module("letsAngular").run(["$templateCache",function(e){e.put("lets/views/crud/crud-detail-list.html",'
    {{field.label}}{{field.label}}{{\'letsfw.actions\'|locale}}
    {{\'letsfw.no_record_found\'|locale}}
    '),e.put("lets/views/crud/crud-edit.html",'
    '),e.put("lets/views/crud/crud-filter.html",'
    '),e.put("lets/views/crud/crud-form-input.html",'
    '),e.put("lets/views/crud/crud-form.html",'
    {{headers.label_row}} {{\'letsfw.main_information\'|locale}}
    {{headers.label_row}} {{\'letsfw.main_information\'|locale}}
    '),e.put("lets/views/crud/crud-list-table.html",'
    {{field.label}} {{field.label}}{{\'letsfw.actions\'|locale}}
    {{parseRecord(data,field)}}
    '), +e.put("lets/views/crud/crud-list.html",'
    '),e.put("lets/views/crud/crud-modal.html",'
    '),e.put("lets/views/crud/crud-tab-list.html",""),e.put("lets/views/crud/crud.html",'
    '),e.put("lets/views/framework/breadcrumb.html",''),e.put("lets/views/framework/chart.html",'

    Relatório de {{key}}

    '),e.put("lets/views/framework/input-detail.html",'
    '),e.put("lets/views/framework/input.html",'
    R$
    • {{field.error}}
    • {{field.error}}
    • A data informada é inválida.
    • {{field.error}}
    • O horário informado é inválido.
    Arraste e solte o arquivo aqui.
    {{f.name}}
    • {{field.error}}
    • {{field.error}}
    {{column.label}}
    {{data[column.name]}}
    '),e.put("lets/views/framework/paginator.html",'
  • {{\'letsfw.records_page\'|locale}}: {{pagesize}} / {{totalrecords}}
  • ')}]); \ No newline at end of file diff --git a/src/directives/crud/lets-crud-list-table.directive.js b/src/directives/crud/lets-crud-list-table.directive.js index ec6fd9d..8093825 100644 --- a/src/directives/crud/lets-crud-list-table.directive.js +++ b/src/directives/crud/lets-crud-list-table.directive.js @@ -194,6 +194,7 @@ $scope.searching = false; $scope.tableData = response; $scope.tableData.currentPage = $scope.currentPage; + $scope.$emit('refreshTable'); }) },function() { $scope.tableData = {}; diff --git a/src/views/framework/input.html b/src/views/framework/input.html index a2ecd47..511b5d2 100644 --- a/src/views/framework/input.html +++ b/src/views/framework/input.html @@ -233,7 +233,7 @@
    + ng-disabled="field.disabled" ng-readonly="field.disabled">