diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..0613896 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,27 @@ +{ + "arrowParens": "always", + "bracketSpacing": false, + "htmlWhitespaceSensitivity": "ignore", + "insertPragma": false, + "jsxBracketSameLine": true, + "jsxSingleQuote": true, + "printWidth": 300, + "proseWrap": "preserve", + "quoteProps": "preserve", + "requirePragma": false, + "semi": true, + "singleQuote": true, + "tabWidth": 2, + "trailingComma": "es5", + "useTabs": true, + "vueIndentScriptAndStyle": false, + "endOfLine": "auto", + "overrides": [ + { + "files": "*.html", + "options": { + "parser": "angular" + } + } + ] +} diff --git a/README.md b/README.md index 27d5a3b..a50873c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -Lets Comunica Angular Framework Core -============= +# Lets Comunica Angular Framework Core This repository was organized within the [AngularJS 1.4.1](https://docs.angularjs.org/api) framework. This repo covers all the core functionalities that our company front-end projects basically needs. @@ -9,8 +8,7 @@ E-mail: fabio@letscomunica.com.br **LAST VERSION: 0.0.20** -Installation -===== +# Installation Install in you angular project: @@ -18,185 +16,267 @@ Install in you angular project: npm install --save git+ssh://git@bitbucket.org/letscomunicadev/angular-framework-core.git#v0.0.20 ``` -Functionalities -===== - This list shows the current supported functionalities. - In order to use one of those just follow the necessary steps, pay attention on the highlighted lines. +# Functionalities + +This list shows the current supported functionalities. +In order to use one of those just follow the necessary steps, pay attention on the highlighted lines. ## Autocomplete - With this feature, if corrected configured on backend, you can set fields to show the values of foreign keys. - Just use *true* on *autocomplete* key, inside your fields options: - ```javascript - { - "name": "fieldName", - "type": "fieldType", - "notnull": true, - "length": null, - "precision": 100, - "label": "fieldLabel", - "editable": true, - "viewable": true, - -> "autocomplete": true, - "quickAdd": [], - "autocomplete_dependencies": [], - "customOptions": [] - } - ``` +With this feature, if corrected configured on backend, you can set fields to show the values of foreign keys. + +Just use _true_ on _autocomplete_ key, inside your fields options: + +```javascript +{ + "name": "fieldName", + "type": "fieldType", + "notnull": true, + "length": null, + "precision": 100, + "label": "fieldLabel", + "editable": true, + "viewable": true, + -> "autocomplete": true, + "quickAdd": [], + "autocomplete_dependencies": [], + "customOptions": [] +} +``` + ## Autocomplete Table - Same of autocomplete but with tables. - Set the autocomplete key as true and use *autocomplete_table* on customOptions. It expects 'table_name' and 'table_columns' as keys: - ```javascript - { - "name": "fieldName", - "type": "string", - "notnull": true, - "length": null, - "precision": 10, - "label": "fieldLabel", - "editable": true, - "viewable": true, - -> "autocomplete": true, - "quickAdd": [], - "autocomplete_dependencies": [], - "customOptions": { - -> "autocomplete_table": { - | "table_name": "medicamentos", - | "table_columns": [ - | { - | "name": "nome_apresentacao", - | "label": "Descrição do Produto" - | }, - | { - | "name": "tipo.label", - | "label": "Tipo" - | }, - | { - | "name": "tarja.label", - | "label": "Tarja" - | } - | ] - -> } - } +Same of autocomplete but with tables. + +Set the autocomplete key as true and use _autocomplete_table_ on customOptions. It expects 'table_name' and 'table_columns' as keys: + +```javascript +{ + "name": "fieldName", + "type": "string", + "notnull": true, + "length": null, + "precision": 10, + "label": "fieldLabel", + "editable": true, + "viewable": true, + -> "autocomplete": true, + "quickAdd": [], + "autocomplete_dependencies": [], + "customOptions": { + -> "autocomplete_table": { + | "table_name": "medicamentos", + | "table_columns": [ + | { + | "name": "nome_apresentacao", + | "label": "Descrição do Produto" + | }, + | { + | "name": "tipo.label", + | "label": "Tipo" + | }, + | { + | "name": "tarja.label", + | "label": "Tarja" + | } + | ] + -> } } - ``` +} +``` + ## Boolean - Simple boolean type input, with toogle. - Just use *boolean* on *type* key, inside your fields options: - ```javascript - { - "name": "fieldName", - -> "type": "boolean", - "notnull": true, - "length": null, - "precision": 10, - "label": "fieldLabel", - "editable": true, - "viewable": true, - "autocomplete": false, - "quickAdd": [], - "autocomplete_dependencies": [], - "customOptions": [] - } - ``` +Simple boolean type input, with toogle. + +Just use _boolean_ on _type_ key, inside your fields options: + +```javascript +{ + "name": "fieldName", + -> "type": "boolean", + "notnull": true, + "length": null, + "precision": 10, + "label": "fieldLabel", + "editable": true, + "viewable": true, + "autocomplete": false, + "quickAdd": [], + "autocomplete_dependencies": [], + "customOptions": [] +} +``` + ## CNPJ - Masked input for CNPJ. - Set the *type* key as *string* and use *cnpj* as *true* on the customOptions key: - ```javascript - { - "name": "fieldName", - -> "type": "string", - "notnull": false, - "length": 100, - "precision": 10, - "label": "fieldLabel", - "editable": true, - "viewable": true, - "autocomplete": false, - "quickAdd": [], - "autocomplete_dependencies": [], - "customOptions": { - -> "cnpj": true - } +Masked input for CNPJ. + +Set the _type_ key as _string_ and use _cnpj_ as _true_ on the customOptions key: + +```javascript +{ + "name": "fieldName", + -> "type": "string", + "notnull": false, + "length": 100, + "precision": 10, + "label": "fieldLabel", + "editable": true, + "viewable": true, + "autocomplete": false, + "quickAdd": [], + "autocomplete_dependencies": [], + "customOptions": { + -> "cnpj": true } - ``` +} +``` + ## CPF - Masked input for CPF. - Set the *type* key as *string* and use *cpf* as *true* on the customOptions key: - ```javascript - { - "name": "fieldName", - -> "type": "string", - "notnull": false, - "length": 100, - "precision": 10, - "label": "fieldLabel", - "editable": true, - "viewable": true, - "autocomplete": false, - "quickAdd": [], - "autocomplete_dependencies": [], - "customOptions": { - -> "cpf": true - } +Masked input for CPF. + +Set the _type_ key as _string_ and use _cpf_ as _true_ on the customOptions key: + +```javascript +{ + "name": "fieldName", + -> "type": "string", + "notnull": false, + "length": 100, + "precision": 10, + "label": "fieldLabel", + "editable": true, + "viewable": true, + "autocomplete": false, + "quickAdd": [], + "autocomplete_dependencies": [], + "customOptions": { + -> "cpf": true } - ``` +} +``` + ## CPF/CNPJ - With this feature the masked input accepts either CPF or CNPJ, according to its lenght. - Set the *type* key as *string* and use *documento* as *true* on the customOptions key: - ```javascript - { - "name": "fieldName", - -> "type": "string", - "notnull": true, - "length": null, - "precision": 10, - "label": "CPF/CNPJ", - "editable": true, - "viewable": true, - "autocomplete": false, - "quickAdd": [], - "autocomplete_dependencies": [], - "customOptions": { - -> "documento": true - } +With this feature the masked input accepts either CPF or CNPJ, according to its lenght. + +Set the _type_ key as _string_ and use _documento_ as _true_ on the customOptions key: + +```javascript +{ + "name": "fieldName", + -> "type": "string", + "notnull": true, + "length": null, + "precision": 10, + "label": "CPF/CNPJ", + "editable": true, + "viewable": true, + "autocomplete": false, + "quickAdd": [], + "autocomplete_dependencies": [], + "customOptions": { + -> "documento": true } - ``` +} +``` + ## Ckeditor - With this feature you can use a rich text editor. - Set the *type* key as *text* and use *rich* as *true* on the customOptions key. - ```javascript - { - "name": "fieldName", - -> "type": "text", - "notnull": true, - "length": null, - "precision": 10, - "label": "fieldLabel", - "editable": false, - "viewable": false, - "autocomplete": false, - "quickAdd": false, - "autocomplete_dependencies": [], - "customOptions": { - -> "rich":true - } +With this feature you can use a rich text editor. + +Set the _type_ key as _text_ and use _rich_ as _true_ on the customOptions key. + +```javascript +{ + "name": "fieldName", + -> "type": "text", + "notnull": true, + "length": null, + "precision": 10, + "label": "fieldLabel", + "editable": false, + "viewable": false, + "autocomplete": false, + "quickAdd": false, + "autocomplete_dependencies": [], + "customOptions": { + -> "rich":true } - ``` +} +``` + ## Currency - Masked input for BRL currency values. - Set the *type* key as *float* and use *currency* as *true* on the customOptions key. - ```javascript +Masked input for BRL currency values. + +Set the _type_ key as _float_ and use _currency_ as _true_ on the customOptions key. + +```javascript +{ + "name": "fieldName", + -> "type": "float", + "notnull": true, + "length": null, + "precision": 10, + "label": "fieldLabel", + "editable": true, + "viewable": true, + "autocomplete": false, + "quickAdd": [], + "autocomplete_dependencies": [], + "customOptions": { + -> "currency": true, + } +} +``` + +## Custom + +On this functionality you can create anything, the example below shows a button that only appears on data listing and formats a text that can be used as email. + +In order to use it set _type_ key as _custom_ and "make" it on _toString_ key: + +```javascript +{ + "name": "fieldName", + -> "type": "custom", + "notnull": false, + "length": null, + "precision": null, + "label": "fieldLabel", + "editable": false, + "viewable": true, + "autocomplete": false, + "quickAdd": [], + "autocomplete_dependencies": [], + "customOptions": [], + -> "toString": function (model) { + | var btn = $(''); + | var messageWindow; + | var corpo = model.attributes.corpo; + | + | btn.click(function () { + | messageWindow = window.open("", "messageWindow", "width=600, height=400"); + | messageWindow.document.write("
" + corpo + "
"); + | }); + | return btn; + -> } +} +``` + +## Date + +New date range picker + +https://github.com/fragaria/angular-daterangepicker + +````javascript { "name": "fieldName", - -> "type": "float", + -> "type": "date", "notnull": true, "length": null, "precision": 10, @@ -206,50 +286,19 @@ Functionalities "autocomplete": false, "quickAdd": [], "autocomplete_dependencies": [], - "customOptions": { - -> "currency": true, - } + "customOptions": [] } - ``` -## Custom - On this functionality you can create anything, the example below shows a button that only appears on data listing and formats a text that can be used as email. + ``` + +## OLDDATE - In order to use it set *type* key as *custom* and "make" it on *toString* key: - ```javascript - { - "name": "fieldName", - -> "type": "custom", - "notnull": false, - "length": null, - "precision": null, - "label": "fieldLabel", - "editable": false, - "viewable": true, - "autocomplete": false, - "quickAdd": [], - "autocomplete_dependencies": [], - "customOptions": [], - -> "toString": function (model) { - | var btn = $(''); - | var messageWindow; - | var corpo = model.attributes.corpo; - | - | btn.click(function () { - | messageWindow = window.open("", "messageWindow", "width=600, height=400"); - | messageWindow.document.write("
" + corpo + "
"); - | }); - | return btn; - -> } - } - ``` -## Date A masked input with date picker. Just use *date* as *type*. ```javascript { "name": "fieldName", - -> "type": "date", + -> "type": "olddate", "notnull": true, "length": null, "precision": 10, @@ -261,281 +310,318 @@ Functionalities "autocomplete_dependencies": [], "customOptions": [] } - ``` +```` + ## Drag and Drop Upload - A drag and drop field for file uploads. - In order to use it set *type* key as *string*, use *dad* as *true* on the customOptions key and fill *file* object with 'container' and 'acceptedFiles' values, *container* must be a folders name and *acceptedFiles* a fileType: - ```javascript - { - "name": "lan_anexo", - -> "type": "string", - "notnull": true, - "length": null, - "precision": 10, - "label": "Anexo", - "editable": true, - "viewable": false, - "autocomplete": false, - "quickAdd": [], - "autocomplete_dependencies": [], - "customOptions": { - -> "dad": true, - | "file": { - | "container": "anexos", - | "acceptedFiles": ".pdf" - -> } - } +A drag and drop field for file uploads. + +In order to use it set _type_ key as _string_, use _dad_ as _true_ on the customOptions key and fill _file_ object with 'container' and 'acceptedFiles' values, _container_ must be a folders name and _acceptedFiles_ a fileType: + +```javascript +{ + "name": "lan_anexo", + -> "type": "string", + "notnull": true, + "length": null, + "precision": 10, + "label": "Anexo", + "editable": true, + "viewable": false, + "autocomplete": false, + "quickAdd": [], + "autocomplete_dependencies": [], + "customOptions": { + -> "dad": true, + | "file": { + | "container": "anexos", + | "acceptedFiles": ".pdf" + -> } } - ``` +} +``` + ## Email - Set the *type* key as *string* and use *email* as *true* on the customOptions key: - ```javascript - { - "name": "fieldName", - -> "type": "string", - "notnull": true, - "length": 100, - "precision": 10, - "label": "fieldLabel", - "editable": true, - "viewable": false, - "autocomplete": false, - "quickAdd": [], - "autocomplete_dependencies": [], - "customOptions": { - -> "email": true - } + +Set the _type_ key as _string_ and use _email_ as _true_ on the customOptions key: + +```javascript +{ + "name": "fieldName", + -> "type": "string", + "notnull": true, + "length": 100, + "precision": 10, + "label": "fieldLabel", + "editable": true, + "viewable": false, + "autocomplete": false, + "quickAdd": [], + "autocomplete_dependencies": [], + "customOptions": { + -> "email": true } - ``` +} +``` + ## Float - A simple float input - Just set the *type* key as *float* and you are good to go: - ```javascript - { - "name": "fieldName", - -> "type": "float", - "notnull": true, - "length": null, - "precision": 10, - "label": "fieldLabel", - "editable": true, - "viewable": true, - "autocomplete": false, - "quickAdd": [], - "autocomplete_dependencies": [], - "customOptions": [] - } - ``` +A simple float input + +Just set the _type_ key as _float_ and you are good to go: + +```javascript +{ + "name": "fieldName", + -> "type": "float", + "notnull": true, + "length": null, + "precision": 10, + "label": "fieldLabel", + "editable": true, + "viewable": true, + "autocomplete": false, + "quickAdd": [], + "autocomplete_dependencies": [], + "customOptions": [] +} +``` + ## List - A select field with custom labels. - Fill the "*type*" key with the value "*number*", set "*autocomplete*" as *true* and create your list on "*customOptions*" key as below: - ```javascript - { - "name": "fieldName", - -> "type": "number", - "notnull": true, - "length": null, - "precision": 10, - "label": "fieldName", - "editable": true, - "viewable": true, - -> "autocomplete": true, - "quickAdd": [], - "autocomplete_dependencies": [], - "customOptions": { - -> "list":[ - | {"id":1, "label":"Janeiro"}, - | {"id":2, "label":"Fevereiro"}, - | {"id":3, "label":"Março"}, - | {"id":4, "label":"Abril"}, - | {"id":5, "label":"Maio"}, - | {"id":6, "label":"Junho"}, - | {"id":7, "label":"Julho"}, - | {"id":8, "label":"Agosto"}, - | {"id":9, "label":"Setembro"}, - | {"id":10, "label":"Outubro"}, - | {"id":11, "label":"Novembro"}, - | {"id":12, "label":"Dezembro"}, - | ], - -> "select":true - } +A select field with custom labels. + +Fill the "_type_" key with the value "_number_", set "_autocomplete_" as _true_ and create your list on "_customOptions_" key as below: + +```javascript +{ + "name": "fieldName", + -> "type": "number", + "notnull": true, + "length": null, + "precision": 10, + "label": "fieldName", + "editable": true, + "viewable": true, + -> "autocomplete": true, + "quickAdd": [], + "autocomplete_dependencies": [], + "customOptions": { + -> "list":[ + | {"id":1, "label":"Janeiro"}, + | {"id":2, "label":"Fevereiro"}, + | {"id":3, "label":"Março"}, + | {"id":4, "label":"Abril"}, + | {"id":5, "label":"Maio"}, + | {"id":6, "label":"Junho"}, + | {"id":7, "label":"Julho"}, + | {"id":8, "label":"Agosto"}, + | {"id":9, "label":"Setembro"}, + | {"id":10, "label":"Outubro"}, + | {"id":11, "label":"Novembro"}, + | {"id":12, "label":"Dezembro"}, + | ], + -> "select":true } - ``` +} +``` + ## Number or Integer - A number input. - Just set the *type* key as *number* or *integer* and you are good to go: - ```javascript - { - "name": "fieldName", - -> "type": "number", - "notnull": true, - "length": null, - "precision": 10, - "label": "fieldLabel", - "editable": true, - "viewable": false, - "autocomplete": false, - "quickAdd": [], - "autocomplete_dependencies": [], - "customOptions": [] - } - ``` +A number input. + +Just set the _type_ key as _number_ or _integer_ and you are good to go: + +```javascript +{ + "name": "fieldName", + -> "type": "number", + "notnull": true, + "length": null, + "precision": 10, + "label": "fieldLabel", + "editable": true, + "viewable": false, + "autocomplete": false, + "quickAdd": [], + "autocomplete_dependencies": [], + "customOptions": [] +} +``` + ## Number or Integer with Range - A number input with range. - Just set the *type* key as *number*, fill *range* object with the 'min' and 'max' values inside customOptions value and you're done: - ```javascript - { - "name": "fieldName", - -> "type": "number", - "notnull": true, - "length": null, - "precision": 10, - "label": "fieldLabel", - "editable": true, - "viewable": true, - "autocomplete": false, - "quickAdd": [], - "autocomplete_dependencies": [], - "customOptions": { - -> "range": { - | "min": 0, - | "max": 10000 - -> } - } +A number input with range. + +Just set the _type_ key as _number_, fill _range_ object with the 'min' and 'max' values inside customOptions value and you're done: + +```javascript +{ + "name": "fieldName", + -> "type": "number", + "notnull": true, + "length": null, + "precision": 10, + "label": "fieldLabel", + "editable": true, + "viewable": true, + "autocomplete": false, + "quickAdd": [], + "autocomplete_dependencies": [], + "customOptions": { + -> "range": { + | "min": 0, + | "max": 10000 + -> } } - ``` +} +``` + ## Password - Password input. - Just set the *type* key as *password* and you are good to go: - ```javascript - { - "name": "fieldName", - -> "type": "password", - "notnull": true, - "length": null, - "precision": 10, - "label": "fieldLabel", - "editable": true, - "viewable": false, - "autocomplete": false, - "quickAdd": [], - "autocomplete_dependencies": [], - "customOptions": [] - } - ``` +Password input. + +Just set the _type_ key as _password_ and you are good to go: + +```javascript +{ + "name": "fieldName", + -> "type": "password", + "notnull": true, + "length": null, + "precision": 10, + "label": "fieldLabel", + "editable": true, + "viewable": false, + "autocomplete": false, + "quickAdd": [], + "autocomplete_dependencies": [], + "customOptions": [] +} +``` + ## Simplecolor - A simple color picker. - Set the *type* key as *simplecolor* and fill *colors* array with the desired colors: - ```javascript - { - "name": "cor", - -> "type": "simplecolor", - "notnull": false, - "length": null, - "precision": 10, - "label": "Sinalização", - "editable": true, - "viewable": false, - "autocomplete": false, - "quickAdd": [], - "autocomplete_dependencies": [], - "customOptions": { - -> colors: ['green', 'yellow', 'orange', 'red'] - } +A simple color picker. + +Set the _type_ key as _simplecolor_ and fill _colors_ array with the desired colors: + +```javascript +{ + "name": "cor", + -> "type": "simplecolor", + "notnull": false, + "length": null, + "precision": 10, + "label": "Sinalização", + "editable": true, + "viewable": false, + "autocomplete": false, + "quickAdd": [], + "autocomplete_dependencies": [], + "customOptions": { + -> colors: ['green', 'yellow', 'orange', 'red'] } - ``` +} +``` + ## String - Just set the *type* key as *string* and you are good to go: - ```javascript - { - "name": "fieldName", - -> "type": "string", - "notnull": true, - "length": null, - "precision": 10, - "label": "fieldLabel", - "editable": true, - "viewable": true, - "autocomplete": false, - "quickAdd": [], - "autocomplete_dependencies": [], - "customOptions": [] - } - ``` + +Just set the _type_ key as _string_ and you are good to go: + +```javascript +{ + "name": "fieldName", + -> "type": "string", + "notnull": true, + "length": null, + "precision": 10, + "label": "fieldLabel", + "editable": true, + "viewable": true, + "autocomplete": false, + "quickAdd": [], + "autocomplete_dependencies": [], + "customOptions": [] +} +``` + ## Tags - I really didn't understand this functionality, fell free to discover and write about it. + +I really didn't understand this functionality, fell free to discover and write about it. + ## Textarea - Just set the *type* key as *text* and you are good to go: - ```javascript - { - "name": "fieldName", - -> "type": "text", - "notnull": true, - "length": null, - "precision": 10, - "label": "fieldLabel", - "editable": true, - "viewable": true, - "autocomplete": false, - "quickAdd": [], - "autocomplete_dependencies": [], - "customOptions": [] - } - ``` + +Just set the _type_ key as _text_ and you are good to go: + +```javascript +{ + "name": "fieldName", + -> "type": "text", + "notnull": true, + "length": null, + "precision": 10, + "label": "fieldLabel", + "editable": true, + "viewable": true, + "autocomplete": false, + "quickAdd": [], + "autocomplete_dependencies": [], + "customOptions": [] +} +``` + ## Time - A time picker. - Just set the *type* key as *time*: - ```javascript - { - "name": "fieldName", - -> "type": "time", - "notnull": true, - "length": null, - "precision": 10, - "label": "fieldLabel", - "editable": true, - "viewable": true, - "autocomplete": false, - "quickAdd": [], - "autocomplete_dependencies": [], - "customOptions": [] - } - ``` +A time picker. + +Just set the _type_ key as _time_: + +```javascript +{ + "name": "fieldName", + -> "type": "time", + "notnull": true, + "length": null, + "precision": 10, + "label": "fieldLabel", + "editable": true, + "viewable": true, + "autocomplete": false, + "quickAdd": [], + "autocomplete_dependencies": [], + "customOptions": [] +} +``` + ## Upload - File upload field with simple button. - In order to use it set *type* key as *string* and fill *file* object, *container* must be a folders name: - ```javascript - { - "name": "lan_anexo", - -> "type": "string", - "notnull": true, - "length": null, - "precision": 10, - "label": "Anexo", - "editable": true, - "viewable": false, - "autocomplete": false, - "quickAdd": [], - "autocomplete_dependencies": [], - "customOptions": { - -> "file": { - | "container": "anexos" - -> } - } +File upload field with simple button. + +In order to use it set _type_ key as _string_ and fill _file_ object, _container_ must be a folders name: + +```javascript +{ + "name": "lan_anexo", + -> "type": "string", + "notnull": true, + "length": null, + "precision": 10, + "label": "Anexo", + "editable": true, + "viewable": false, + "autocomplete": false, + "quickAdd": [], + "autocomplete_dependencies": [], + "customOptions": { + -> "file": { + | "container": "anexos" + -> } } - ``` +} +``` -Updates -===== +# Updates Made a modification or added a new feature? Test it at least in one project before submiting a version. It still needs unit testing and CI with projects. After everything seems perfectly up-to-date, don't forget to UPDATE THE README file and only then run the following steps: @@ -559,8 +645,8 @@ $ git push origin vX.X.X # Version needs to be the same from commit npm install --save git+ssh://git@bitbucket.org/letscomunicadev/angular-framework-core.git#vX.X.X ``` -Todo ----------- +## Todo + 1\. Convert ng-includes from URL images to directives (in order to access templates from inside this module) 2\. Start gulp automation to render all src files to single lets-angular-framework-core.module.js in a minified version @@ -569,8 +655,7 @@ Todo 4\. Isolate scope to vm and change all scope parents and childs access -History ----------- +## History **v0.0.20** diff --git a/bower.json b/bower.json index 408ecc8..8a45dcc 100644 --- a/bower.json +++ b/bower.json @@ -1,69 +1,61 @@ { - "name": "lets-angular-framework-core", - "version": "0.0.9", - "description": "Core Module for Lets Angular Framework Dependencies", - "authors": [ - "Lets Comunica" - ], - "dependencies": { - "angular": "1.4.1", - "angular-animate": "1.4.0", - "angular-cookies": "1.3.4", - "angular-touch": "1.3.4", - "angular-sanitize": "1.3.4", - "ngstorage": "0.3.7", - "jquery": "2.1.3", - "angular-ui-router": "0.2.13", - "bootstrap-sass": "3.3.4", - "angular-bootstrap": "~0.13.3", - "font-awesome": "~4.7.0", - "open-sans-fontface": "1.4.0", - "animate.css": "3.3.0", - "slimScroll": "1.3.6", - "widgster": "0.0.2", - "jquery-touchswipe": "1.6.9", - "angular-ui-event": "1.0.0", - "backgrid": "0.3.5", - "backgrid-paginator": "03632df8ad238e3d043c0fd471a6c78494e1bdfc", - "datatables": "~1.10.7", - "angular-resource": "~1.4.3", - "underscore": "~1.8.3", - "backbone": "~1.2.1", - "backbone.paginator": "~2.0.2", - "parsleyjs": "~2.1.3", - "restangular": "^1.5.2", - "angular-viacep": "^0.1.0", - "ng-cpf-cnpj": "^0.0.5", - "angular-ui-utils": "bower-jq", - "angular-ui-mask": "^1.8.3", - "moment": "^2.13.0", - "backgrid-moment-cell": "^0.3.8", - "satellizer": "^0.14.0", - "backgrid-filter": "^0.3.7", - "jquery-mask-plugin": "igorescobar/jQuery-Mask-Plugin#^1.14.0", - "angular-i18n": "^1.5.6", - "ngToast": "ngtoast#^2.0.0", - "PACE": "pace-ng-file-upload-patch#^1.0.3", - "ng-file-upload": "^12.0.4", - "angular-timer": "^1.3.5", - "angular-moment-filter": "*", - "checklist-model": "^0.11.0", - "moment-duration-format": "^2.2.1", - "angular-bootstrap-toggle": "^0.1.3", - "ng-dropzone": "https://github.com/thatisuday/ng-dropzone.git#v2.0.2", - "swangular": "^1.4.3", - "angularjs-dropdown-multiselect": "^1.11.8" - }, - "devDependencies": {}, - "main": [ - "./dist/lets.min.js", - "./dist/lets.min.css" - ], - "ignore": [], - "keywords": [ - "angular", - "directive", - "module" - ], - "license": "MIT" + "name": "lets-angular-framework-core", + "version": "0.0.9", + "description": "Core Module for Lets Angular Framework Dependencies", + "authors": ["Lets Comunica"], + "dependencies": { + "angular": "1.4.1", + "angular-animate": "1.4.0", + "angular-cookies": "1.3.4", + "angular-touch": "1.3.4", + "angular-sanitize": "1.3.4", + "ngstorage": "0.3.7", + "jquery": "2.1.3", + "angular-ui-router": "0.2.13", + "bootstrap-sass": "3.3.4", + "angular-bootstrap": "~0.13.3", + "font-awesome": "~4.7.0", + "open-sans-fontface": "1.4.0", + "animate.css": "3.3.0", + "slimScroll": "1.3.6", + "widgster": "0.0.2", + "jquery-touchswipe": "1.6.9", + "angular-ui-event": "1.0.0", + "backgrid": "0.3.5", + "backgrid-paginator": "03632df8ad238e3d043c0fd471a6c78494e1bdfc", + "datatables": "~1.10.7", + "angular-resource": "~1.4.3", + "underscore": "~1.8.3", + "backbone": "~1.2.1", + "backbone.paginator": "~2.0.2", + "parsleyjs": "~2.1.3", + "restangular": "^1.5.2", + "angular-viacep": "^0.1.0", + "ng-cpf-cnpj": "^0.0.5", + "angular-ui-utils": "bower-jq", + "angular-ui-mask": "^1.8.3", + "moment": "^2.13.0", + "backgrid-moment-cell": "^0.3.8", + "satellizer": "^0.14.0", + "backgrid-filter": "^0.3.7", + "jquery-mask-plugin": "igorescobar/jQuery-Mask-Plugin#^1.14.0", + "angular-i18n": "^1.5.6", + "ngToast": "ngtoast#^2.0.0", + "PACE": "pace-ng-file-upload-patch#^1.0.3", + "ng-file-upload": "^12.0.4", + "angular-timer": "^1.3.5", + "angular-moment-filter": "*", + "checklist-model": "^0.11.0", + "moment-duration-format": "^2.2.1", + "angular-bootstrap-toggle": "^0.1.3", + "ng-dropzone": "https://github.com/thatisuday/ng-dropzone.git#v2.0.2", + "swangular": "^1.4.3", + "angularjs-dropdown-multiselect": "^1.11.8", + "angular-daterangepicker": "^0.3.0" + }, + "devDependencies": {}, + "main": ["./dist/lets.min.js", "./dist/lets.min.css"], + "ignore": [], + "keywords": ["angular", "directive", "module"], + "license": "MIT" } diff --git a/dist/lets.min.js b/dist/lets.min.js index e0674d2..e3c32e8 100644 --- a/dist/lets.min.js +++ b/dist/lets.min.js @@ -1,4 +1,4 @@ -!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,o,l,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,h='
',b='
',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),o.replaceWith(f),c=h+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"===o[0].tagName?(c=h+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?o[0].style.backgroundColor=t:o.val(t)}),n.$watch("ngModel",function(e,t){var a=e;void 0!=a&&void 0!==n.colorMe&&"true"===n.colorMe&&(o[0].style.backgroundColor=a,o[0].value="")}),angular.element(document.body).append(p),o.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),o.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,o=a.getBoundingClientRect().height;n+=i.pageYOffset,p.removeClass("hide"),p[0].style.top=n+o+"px",p[0].style.left=a.getBoundingClientRect().left+"px",e.stopPropagation()}),t(u)(n)):(c=b+c,p=t(c)(n),o.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;ti;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 o="["+i.toUpperCase()+"]";if(-1!==t.indexOf(o)){var l=t.split(o),r="",s=l.length;l.forEach(function(t,o){r+=t,s-1>o&&(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(o,l){moment.locale("pt-br");var r=angular.extend(t.$new(),l);e(o).then(function(e){var t=a($("
"+e+"
"))(r),o=function(){r.$$phase?i(o):(n._printHTML(t.html()),r.$destroy())};o()})},{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 o=a;"id"!==a&&(o="label"),"label"===o&&t&&i===t.relation?n.label=e[i][t.label]:n[o]=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,o,l){var r=t.slice(0),s=Object.keys(l).length,c=e._getFilledFilterAttr(a,n),d="neutral";c.checkboxes.forEach(function(e){n[e].length>o[e].length?d="add":n[e].lengtha[t]?1:0}):e},e.getMinMaxValues=function(e,t,a,i,n,o,l){var r={x:l[0][t],y:l[0][n]},s={x:l[0][t],y:l[0][n]};return l.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(o,"day").format("MM/DD/YYYY")),s.y=new Date(moment(s.y).add(o,"day").format("MM/DD/YYYY"))):(r.y-=o,s.y+=o),{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,o){return i._createModal({animation:!0,templateUrl:o||"lets/views/crud/crud-modal.html",controller:n||"CRUDFormModalController",resolve:{headers:function(){return e},data:function(){try{var e=angular.copy(a)}catch(i){var e=t.extend({},a)}return e}},size:"lg",backdrop:"static",keyboard:!1})},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 o in i){var l=t.$error[i[o]];for(var r in l){var s=l[r].$options.fieldInfo.label;"required"==i[o]?a.push("O campo "+s+" é obrigatório"):"date"==i[o]&&0==n.test(l[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,o,l,r){var s=o.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 l.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";function e(e){return{restrict:"A",scope:!0,link:function(t,a,i){t.defaultProgress=0,t.alreadySent=!1;var n=!0;t.$on("setProgressFile",function(){void 0!=t.data[t.field.name]&&null!=t.data[t.field.name]&&t.fileName&&"fileName"!=t.fileName&&(t.defaultProgress=100,t.alreadySent=!0)}),t.pushName=function(){e(function(){if(document.getElementsByClassName("dz-filename")[0]&&n){n=!1,document.getElementsByClassName("dropzone")[0].style.width="192px",document.getElementsByClassName("file-preview")[0]&&(document.getElementsByClassName("file-preview")[0].style.display="none"),document.getElementsByName("temp_filename")[0].value=document.getElementsByClassName("dz-filename")[0].firstElementChild.innerText;var e=i.find('input[type="hidden"]');e.controller("ngModel").$setViewValue(document.getElementsByName("temp_filename")[0].value)}})},t.remove=function(){t.alreadySent=!1;var e=i.find('input[type="hidden"]');document.getElementsByName("temp_filename")[0].value=null,e.controller("ngModel").$setViewValue(null)},t.upload=function(a,n){t.f=a,t.errFile=n&&n[0],a&&(a.upload=t._upload(t.field,a),a.upload.then(function(n,o){t.$emit("upload-complete",n),e(function(){if(a.result=n.data,i.$$element)var e=i.$$element.find('input[type="hidden"]');else var e=i.find('input[type="hidden"]');a.newName=n.data.result.files.file[0].name,e.controller("ngModel").$setViewValue(a.newName)})},function(e){e.status>0&&(t.errorMsg=e.status+": "+e.data),t.$emit("upload-error",e)},function(e){a.progress=Math.min(100,parseInt(100*e.loaded/e.total))}))}}}}angular.module("letsAngular").directive("fwUpload",e),e.$inject=["$timeout"]}(),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";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,o,l){t(function(){n||(n="[blank]");var r=l?"general/":"";e.resource=a.all(e.route()),e.resource.customGET(r+"autocomplete/"+o+"/"+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,o=a.customOptions.general?!0:!1;if(!i.initMultiSelect){var l=i.scope();i.initMultiSelect=!0,e.makeRequestAutocomplete(l,"[blank]",n,o),i.parent().find(".dropdown-header").append(''),l.$watch("input.searchFilter",e._debounce(function(t){e.makeRequestAutocomplete(l,t,n,o)})),l.texts.buttonDefaultText="Selecione "+a.label,l.texts.searchPlaceholder="Buscar "+a.label,l.texts.dynamicButtonTextSuffix="selecionado(s)",l.externalEvents.onItemSelect=e.onItemSelect,l.externalEvents.onSelectionChanged=e.changedMultiSelect,l.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,o,l,r){var s=o.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)o.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(o.contents())(t)}i(o).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,o,l){if(l||(l=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}),l.$parsers.unshift(function(e){return parseFloat(n.cleanVal(),10)/100}),l.$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,o){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 o=t[a.name],o=o.toFixed(2).split(".");return o[0]="R$ "+o[0].split(/(?=(?:...)*$)/).join("."),o.join(",")}return t[a.name]}if("custom"==a.type){var l=a.toString({attributes:t});return l&&l[0]&&l[0].outerHTML?n.trustAsHtml(l[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 o=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(o),o.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 o="dd/MM/yyyy";void 0!==t.field.customOptions.monthpicker&&(n.datepickerMode="'month'",n.minMode="month",o="MM/yyyy"),a.find("input").attr("datepicker-popup",o),a.find("input").blur(function(){moment(this.value,o).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,o){var l=o[0],r=o[1];l.ready().then(function(){["dataReady","change","blur","saveSnapshot"].forEach(function(e){ -l.onCKEvent(e,function(){r.$setViewValue(l.instance.getData()||"")})}),l.instance.setReadOnly(!!n.readonly),n.$observe("readonly",function(e){l.instance.setReadOnly(!!e)}),i(function(){e(n.ready)(t)})}),r.$render=function(){l.ready().then(function(){l.instance.setData(r.$viewValue||"",{noSnapshot:!0,callback:function(){l.instance.fire("updateSnapshot")}})})}}}}function a(e,t,a,n,o){var l,r=n(a.ckeditor)(e)||{},s=t[0],c=o.defer();l=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(){o.apply(null,e)})}function o(){var t=arguments;e.$apply(function(){a.apply(null,t)})}return l.on(t,n),function(){l.removeListener(t,o)}},this.onCKEvent("instanceReady",function(){c.resolve(!0)}),this.ready=function(){return c.promise},e.$on("$destroy",function(){c.promise.then(function(){l.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(),o=n.chart_settings,l=i.crudChartData();i.key=n.key,i.d3chartUpdate=!1;var r=t.getMinMaxValues(o.xType,o.xLabel,o.xOffset,o.yType,o.yLabel,o.yOffset,l),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,l),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(){var e=i.val(),a=e+" ";i.controller("ngModel").$setViewValue(a),t(function(){i.controller("ngModel").$setViewValue(e)})};a.find("button").click(n),i.click(n),i.keyup(function(){""==this.value.trim()&&(i.scope().data[i.attr("name")]=null)})},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,o){var l=i.find(":input").val().split(" "),r="/^("+l[0]+")";l.splice(0,1),l.forEach(function(e){r+="(?=.*"+e+")"}),r+=".*/i";var s='{"limit": 5,"where":{"'+o+'":{"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,o,l,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)})}],link:function(o,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 o={fromRaw:e.toString,toRaw:function(e,t){return"down"}};n.sortable=!1;var l=i.Cell.extend({className:"custom-cell",formatter:o});l.initialize=function(){i.Cell.prototype.initialize.apply(this,arguments)},l.render=function(){this.$el.empty(),this.$el.data("model",this.model);var e=o.fromRaw(this.model);return this.$el.append(e),this.delegateEvents(),this},n.cell=i.Cell.extend(l)}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 l=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("Deseja realmente excluir esse registro?");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("Deseja realmente excluir esse registro?");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:"Ações",sortable:!1,cell:l}),o.$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 u=new i.Grid({row:s,columns:a,collection:e,className:d}),f=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"}}});o.$el.find(".table-container").html("").append(u.render().$el).append(f.render().$el),setTimeout(function(){angular.element(f.render().$el).click(function(){window.scrollTo({top:100,behavior:"smooth"})})},0),o.$broadcast("refreshGRID",!0)}var c=o.crudListSettings();c.route=n.API_URL+c.url,o.route=c.route,i.InputCellEditor.prototype.attributes["class"]="form-control input-sm";var d=a.Model.extend({}),u={model:d,url:c.route+(c.pagerGeneral?"/pagerGeneral":"/pager"),state:{pageSize:20},mode:"server",parseRecords:function(e,t){return o.$el[0].parseRecords&&"function"==typeof o.$el[0].parseRecords?o.$el[0].parseRecords(e.data):e.data},parseState:function(e,a,i,n){return l(function(){var a=t("
    ");a.append(t("
  • ").html("Registros na página: "+e.total_entries+" / "+e.total_count)),o.$el.find(".table-container .backgrid-paginator ul.total-records").remove(),o.$el.find(".table-container .backgrid-paginator").append(a)}),o.$parent.totalPager=e.total_count,{totalRecords:e.total_count}}};c.filterScope&&(u.queryParams={scope:c.filterScope}),c.sort&&(u.state.sortKey=c.sort.sortKey,c.sort.order&&"desc"==c.sort.order&&(u.state.order=1));var f=a.PageableCollection.extend(u),p=new f;o.pageableCRUDModel=p;var m=angular.copy(p.fetch);p.fetch=function(t,a,i){l(function(){i&&(p.state.currentPage=1);var n=o.$el.attr("grid"),l=$('div[crud-filter][grid="'+n+'"] input').scope();if(l||(l={}),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&&(l.data.p=s.p,p.state.currentPage=parseInt(s.p)),s.q)l.data.q=s.q;else{l=l||{};var c=!1;Object.keys(s).forEach(function(e){if(e.split("_label").length>1)l.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?l.data[e+"_"+t]=moment(s[e][t],"DD/MM/YYYY").toDate():s[e][t].id&&s[e][t].label?l.data[e]=s[e]:(l.data[e]=l.data[e]||{},l.data[e][t]=s[e][t]);else l.data[e]=s[e];"p"!=e&&(c=!0)}),l.data.showBusca=c}l.filterData(!1)}}else if("main"==n){var d=[];if(l.objFilter&&l.objFilter.data.q&&d.push("q="+l.objFilter.data.q),l.objFilter&&l.objFilter.data.filter&&Object.keys(l.objFilter.data.filter).length>0)for(var u in l.objFilter.data.filter)if("object"==typeof l.objFilter.data.filter[u]){if(l.objFilter.data.filter[u].ini&&d.push(u+"_ini="+l.objFilter.data.filter[u].ini),l.objFilter.data.filter[u].fim&&d.push(u+"_fim="+l.objFilter.data.filter[u].fim),!l.objFilter.data.filter[u].ini&&!l.objFilter.data.filter[u].fim){var f=l.objFilter.data.filter[u];d.push(u+"="+JSON.stringify(f))}}else"p"!=u&&d.push(u+"="+l.objFilter.data.filter[u]);p.state&&p.state.currentPage&&1!=p.state.currentPage&&d.push("p="+p.state.currentPage);var g=d.join("&");r.transitionTo(r.$current.name,{filter:g},{location:!0,inherit:!0,relative:r.$current,notify:!1})}l&&l.objFilter&&l.objFilter.data.q&&(t=t||{data:{}},t.data=t.data||{},t.data.q=l.objFilter.data.q,l.objFilter.data.p&&a&&(t.data.page=l.objFilter.data.p,p.state.currentPage=parseInt(l.objFilter.data.p))),l.objFilter&&l.objFilter.data.filter&&Object.keys(l.objFilter.data.filter).length>0&&(t=t||{data:{}},t.data=t.data||{},t.data.filter=l.objFilter.data.filter,l.objFilter.data.filter.p&&a&&(t.data.page=l.objFilter.data.filter.p,p.state.currentPage=parseInt(l.objFilter.data.filter.p))),m.call(p,t)})},s(p)}o.$el=s;var u=o.$parent.$watch("headers",function(e,t){if(null!=e){var a=o.crudListSettings();if(1==a.tab)var i=o.$parent.$watch("data",function(e,t){void 0!=e.id&&(d(),i(),u())});else d(),u()}})}}}angular.module("letsAngular").directive("crudList",e),e.$inject=["$window","jQuery","Backbone","Backgrid","appSettings","fwObjectService","$timeout","$state"]}(),function(){"use strict";function e(e,t,a){return{replace:!1,link:function(i,n){for(var o in i.headers.fields){var l=i.headers.fields[o];l.customOptions.file&&(i.dzOptions={url:a.API_URL+"upload/"+l.customOptions.file.container+"/upload",acceptedFiles:l.customOptions.file.acceptedFiles,maxFilesize:"25",maxFiles:"1",uploadMultiple:!1,addRemoveLinks:!0})}i.dzMethods={},i.removeNewFile=function(){i.dzMethods.removeFile(i.newFile)},e(n).on("click",".button-new",function(){var t=e(this).attr("detail"),a=e(this).attr("origin"),n="true"==e(this).attr("form-modal");i.newDetailData(a,t,n)}),t(function(){n.find(".tab-group .nav-tabs li:first").find("a").click(),n.find(':input[type!="hidden"]:first').focus()},500),$(n).parsley({priorityEnabled:!1,errorsContainer:function(e){return e.$element.closest(".input-container")}})}}}angular.module("letsAngular").directive("crudForm",e),e.$inject=["jQuery","$timeout","appSettings"]}(),function(){"use strict";function e(e,t,a,i){return{templateUrl:"lets/views/crud/crud-filter.html",replace:!0,scope:{fields:"&",route:"&",search:"&",clearButton:"=clearButton"},controller:["$scope",function(e){}],link:function(n,o){n.data={},n.showBuscaAvancada=!1;var l;n.fieldsFilter=[],n.startFilters=function(){l=angular.copy(n.fields()),n.fieldsFilter=[],l=l.filter(function(e){return e.filter}),l.forEach(function(e,t){if(e.filter){if(e.disabled=!1,e.notnull=!1,e.name=e.name,e.customOptions.file&&delete e.customOptions.file,e.customOptions.multiselect&&(e.type="multiselect",e.autocomplete=!1),"text"==e.type)e.type="string";else if("boolean"==e.type)e.type="number",e.autocomplete=!0,e.customOptions={list:[{id:"false",label:e.customOptions.statusFalseText},{id:"true",label:e.customOptions.statusTrueText}],select:!0};else if("date"==e.type){if("object"==typeof e.filter&&e.filter.range===!0){var a=angular.copy(e);a.name+="_ini",a.label+=" (Início)",n.fieldsFilter.push(a);var i=angular.copy(e);return i.name+="_fim",i.label+=" (Término)",void n.fieldsFilter.push(i)}}else if(("number"==e.type||"integer"==e.type||"float"==e.type||"bigint"==e.type)&&"object"==typeof e.filter&&e.filter.range===!0){var a=angular.copy(e);a.name+="_ini",a.label+=" (Início)",n.fieldsFilter.push(a);var i=angular.copy(e);return i.name+="_fim",i.label+=" (Término)",void n.fieldsFilter.push(i)}n.fieldsFilter.push(e)}}),n.fieldsFilter=n.fieldsFilter.sort(function(e,t){var a=e.filter.sequence||0,i=t.filter.sequence||0;return a-i}),setTimeout(function(){n.$emit("filter-init",n),n.$broadcast("filter-init",n)},500)},n.autocomplete=function(a,i){n.$emit("before-filter-autocomplete",n),n.resource=t.all(n.route());var o=[],l=e.defer();if(a.autocomplete_dependencies.length>0){var r=a.autocomplete_dependencies;for(var s in r){var c=r[s];if(void 0==n.data[c.field]||null==n.data[c.field]||"null"==n.data[c.field]){var d="Selecione antes o(a) "+c.label,u=[];return u.push({id:null,label:d}),l.resolve(u),l.promise}o[c.field]=n.data[c.field]}}if(i=i.trim(),(0==i.length||1==a.customOptions.select)&&(i="[blank]"),void 0!==a.customOptions.general)n.resource.customGET("general/autocomplete/"+a.customOptions.general+"/"+i,o).then(function(e){l.resolve(e)},function(){return l.reject()});else if(void 0==a.customOptions.list){var f="autocomplete/"+a.name+"/"+i;1==a.customOptions.select?o.limit=0:o.limit=20,n.resource.customGET(f,o).then(function(e){e.unshift({id:"null",label:"[Em Branco]"}),e.unshift({id:null,label:"--- Selecione ---"}),l.resolve(e)},function(){return l.reject()})}else{var p=angular.copy(a.customOptions.list)||[];1==a.customOptions.select&&(a.customOptions.onlyList||p.unshift({id:"null",label:"[Em Branco]"}),a.customOptions.required||p.unshift({id:null,label:"--- Selecione ---"})),l.resolve(p)}return l.promise},n.autocompleteSelect=function(e,t,i){n.$emit("after-filter-autocomplete",{scope:n,name:this.field.name,value:e});var o=this.data;if(void 0==o&&(o={}),null!=e.id&&"integer"!=typeof e.id||"integer"==typeof e.id&&e.id>0)o[this.field.name]=e.id;else{if(null!=e.id)return o[this.field.name+".label"]=null,!1;o[this.field.name]=o[this.field.name+".label"]=null}this.data=o;var l=this.field;a(function(){jQuery("#"+l.name).trigger("keyup")})},n.filterData=function(e){n.objFilter=void 0;var t={};n.data.showBuscaAvancada&&(n.showBuscaAvancada=angular.copy(n.data.showBuscaAvancada),delete n.data.showBuscaAvancada),n.showBuscaAvancada||n.data.showBusca?(l.forEach(function(e,a){if("object"==typeof e.filter&&e.filter.range===!0){var i={};n.data[e.name+"_ini"]&&(i.ini=n.data[e.name+"_ini"],"date"==e.type&&(i.ini=n.getDateFormated(i.ini))),n.data[e.name+"_fim"]&&(i.fim=n.data[e.name+"_fim"],"date"==e.type&&(i.fim=n.getDateFormated(i.fim))),Object.keys(i).length>0&&(t[e.name]=i)}n.data[e.name]&&(t[e.name]=n.data[e.name],e.customOptions&&e.customOptions.telefone&&(t[e.name]=n.data[e.name].replace(/\D/g,"")),"date"==e.type&&(t[e.name]=n.getDateFormated(t[e.name])),e.autocomplete&&!e.customOptions.multiselect&&(t[e.name+"_label"]=n.data[e.name+".label"].label),e.autocomplete&&e.customOptions.multiselect&&(t[e.name]=n.data[e.name]))}),n.data.q=null,n.objFilter={data:{filter:t}}):(t.q=n.data.q,t.p=n.data.p,n.objFilter={data:t}),e&&i.$broadcast("refreshGRID",!1,!0)},n.openBuscaAvancada=function(){n.showBuscaAvancada=!n.showBuscaAvancada},n.clearBusca=function(){Object.keys(n.data).forEach(function(e){n.data[e]=null}),n.filterData(!0)},n.getDateFormated=function(e){return moment(e).format("DD/MM/YYYY")},n.startFilters(),n.$on("refresh-fields",function(e,t){n.startFilters()}),"fixed"==n.search()&&(n.showBuscaAvancada=!0,n.hideInputSearch=!0)}}}angular.module("letsAngular").directive("crudFilter",e),e.$inject=["$q","Restangular","$timeout","$rootScope"]}(),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 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";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","$stateParams","$rootScope","headers","swangular","ngToast",function(e,t,a,i,n,o,l,r,s,c){function d(){var t=angular.copy(r.get(a));e.headers=t}e.headersReady=!1,e.export_btn_is_disable=!1,d(),e.$on("refresh-headers",function(){d()}),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=[],o=t.slice(1);return e.forEach(function(e){n.append(e[t[0]])}),i(n,o)}var n=e[t[0]],o=t.slice(1),o=t.slice(1);return i(n,o)}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 o=Object.keys(e);if(Array.isArray(e[o[0]])){var l=e[o[0]];l.forEach(function(e){n([e],t,a)})}}a=""})}function o(e){var i=e.fields.filter(t).map(a);if(e.tabs)for(var n in e.tabs){var l=o(e.tabs[n]);if(l){var r={};r[n]=l,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=o(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 l(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 r(e){var t={};e=e.split("&");for(var a=0;a',o+='",o+="
",h.push("m_"+r+i),b.push(a.join("#")+"#"+i)}}else i+1>0||(t.push(e.real_name),a.push(i)),o+=d(n,t,a)}),o}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 c.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=o(e.headers),g='
',h=[],b=[];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+="
",h.push("m_"+y),b.push(y)):g+=d(m[v],[],[])}g+="
",s.swal({title:"Selecione as Colunas Desejadas",html:g,preConfirm:function(){var e=h.map(function(e){return document.getElementById(""+e).checked});return e},showCancelButton:!0}).then(function(t){if(t.value&&e.totalPager&&void 0!=e.totalPager){s.swal({html:"Por favor aguarde, estamos buscando os dados.",allowOutsideClick:!1,allowEscapeKey:!1,onOpen:function(){s.showLoading()}});var a=b.filter(function(e,a){return t.value[a]}),o=r(u);o=Object.assign({},o,{per_page:f}),p.customGET("pager",o).then(function(t){function o(){var o=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,o){return o===n.length-1?(t?t[a]=i(e,n):"",t):t?t[a]=t[a]?t[a]:{}:""},t)}}),t}),r=[];n(m,r,""),o.map(function(e){var t=r;t.forEach(function(t){var a=l(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]]})}),s.close();var c=XLSX.utils.json_to_sheet(o),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,o),e.$$listeners["before export"]||o()})}else void 0==e.totalPager||t.dismiss||s.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})}}])}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDFormModalController",["$controller","$scope","$modalInstance","ngToast","headers","Restangular","$stateParams","$timeout","$state","$rootScope","$q","$http","Upload","$modal","data","fwStringService","auth","fwObjectService","fwErrorService",function(t,a,i,n,o,l,r,s,c,d,u,f,p,m,g,h,b,v,y){t("CRUDEditController",{$scope:a,Restangular:l,$stateParams:r,$timeout:s,$modal:m,module:e,$state:c,$rootScope:d,$q:u,ngToast:n,$http:f,Upload:p}),a.data=g||{},a.headers=o,a.resource=l.all(o.route);for(var w in a.headers.fields){var $=a.headers.fields[w];"boolean"==$.type&&void 0==a.data[$.name]&&($.customOptions["default"]?a.data[$.name]=!0:a.data[$.name]=!1)}o.modal_id&&d.$emit("open:"+o.modal_id,a),a.cancel=function(){i.dismiss("cancel")},a.submit=function(){this.crudForm.$valid?i.close(a.data):y.emitFormErrors(this.crudForm)},d.$on("cancel-modal",function(e,t){i.dismiss("cancel")}),s(function(){a.$broadcast("setProgressFile")})}])}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDEditController",["$scope","Restangular","$stateParams","$timeout","$modal","module","$state","$rootScope","$q","ngToast","$http","Upload","fwModalService","$window",function(e,t,a,i,n,o,l,r,s,c,d,u,f,p){e.data={},e.dataLoaded=!1,e.module=o,e.$http=d,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(){if(a.id)e.$parent.resource.customGET("crudGET/"+a.id).then(function(t){for(var a in e.headers.fields){var n=e.headers.fields[a];if("date"==n.type&&void 0!=t[n.name]&&null!=t[n.name]){var o=new Date(t[n.name]);o.setHours(o.getHours()+o.getTimezoneOffset()/60),t[n.name]=o}n.customOptions&&void 0!=n.customOptions.list&&n.customOptions.list.forEach(function(e){e.id==t[n.name]&&(t[n.name+".label"]=e.label)}),"password"==n.type&&(n.notnull=!1),n.customOptions&&void 0!=n.customOptions.file&&(e.fileName=t[n.name])}e.data=t,e.dataLoaded=!0,i(function(){e.$broadcast("setProgressFile")}),e.$emit("data-loaded")});else{i(function(){e.$emit("data-new")},50);for(var t in e.headers.fields){var n=e.headers.fields[t];"boolean"==n.type&&(e.data[n.name]=n.customOptions["default"]?n.customOptions["default"]:!1)}e.dataLoaded=!0,e.$emit("data-loaded")}},e.headersReady&&e.fetchData(),e.$on("headers-set",function(){e.fetchData()}),e._upload=function(e,t){var a=r.appSettings.API_URL;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/"+e.customOptions.file.container+"/upload":void 0!=e.customOptions.file.url&&void 0!=e.customOptions.file.container&&(a+="upload/"+e.customOptions.file.container+"/"+e.customOptions.file.url),u.upload({url:a,data:{file:t}})},e.download=function(t,a){if(void 0!=t.customOptions.file.container)var i=r.appSettings.API_URL+"upload/"+t.customOptions.file.container+"/download/"+e.data[t.name];else var i=r.appSettings.API_URL+e.module+"/download/"+t.name+"/"+a;e._download(i,t,e.data)},e.downloadDetail=function(t,a,i,n){if(void 0!=a.customOptions.file.container)var o=r.appSettings.API_URL+"upload/"+a.customOptions.file.container+"/download/"+n[a.name];else var o=r.appSettings.API_URL+e.module+"/details/"+t+"/download/"+a.name+"/"+i;e._download(o,a,n)},e._download=function(t,a,i){this.$http({ -method:"GET",url:t,responseType:"arraybuffer"}).success(function(t,n,o){if(o=o(),void 0!=a.customOptions.file.container)var l=i[a.name];else var l=o["content-disposition"].split(";")[1].split("=")[1].split('"')[1];var r=o["content-type"],s=new Blob([t],{type:r});e.downloadFile(s,l)})},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(o){}},e.getFilter=function(){return decodeURIComponent(p.location.search).replace("?filter=","")},e.submit=function(){function t(t){if(t)i.loading_http_request=!1,t.message?c.warning(t.message):c.warning("Confira seu formulário");else{i.headers.tabs&&Object.keys(i.headers.tabs).forEach(function(e){i.data[e]&&delete i.data[e]});var n;if(a.id){n=e.data.put();var o="edit"}else{n=e.$parent.resource.post(e.data);var o="new"}n.then(function(t){function a(){i.loading_http_request=!1,l.go(l.current.name.replace(".edit",".list").replace(".new",".list"),{filter:e.getFilter()})}e.$emit("after save",a,t,o),e.$$listeners["after save"]||a()},function(t){function a(e){for(var t in i.headers.fields){var a=i.headers.fields[t];if(a.name==e)return a.label}}var n=[];if(i.loading_http_request=!1,422==t.status)if("CANT_SAVE_MODEL"==t.data.error.code)n.push(t.data.error.message);else if(t.data.error.details){var o=t.data.error.details.codes,l={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(o,function(e,t){var i=a(t);"string"==typeof e&&(e=[e]),_.each(e,function(e,t){var a=l[e].replace("%s",i);n.push(a)})})}else n.push(t.data.error.message);c.warning(n.join("
")),e.$emit("error save",t)})}}var i=this,n={},o=i.data;if(_.each(i.headers.fields,function(e,t){o[e.name]||0==o[e.name]||e.notnull||"number"!==e.type||(o[e.name]=null),"password"==e.type&&0!=e.name.indexOf("confirm")&&o["confirm_"+e.name]!=o[e.name]&&(n.password='Os campos "'+e.label+'" e "Confirmar '+e.label+'" não são iguais')}),_.each(i.data,function(e,t){-1!==t.indexOf(".label")&&void 0===o.id&&"object"!=typeof e&&""!==e&&(n[t]="Adicione o(a) "+t.split(".")[0]+" no sistema antes de escolher nesse formulário!"),"data_nascimento"===t&&(moment(e).isAfter(moment())||moment(e).isSame(moment(),"day"))&&(n[t]="Insira uma data de nascimento válida, anterior ao dia de hoje!")}),Object.keys(n).length>0){var r=new Array;_.each(n,function(e,t){r.push(e)}),c.warning(r.join("
"))}else if(this.crudForm.$valid)i.loading_http_request=!0,e.$emit("before save",t),e.$$listeners["before save"]||t();else{var s=[],d=Object.keys(this.crudForm.$error),u=/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/;for(var f in d){var p=this.crudForm.$error[d[f]];for(var m in p){var g=p[m].$options.fieldInfo.label;"required"==d[f]?s.push("O campo "+g+" é obrigatório"):"date"==d[f]&&0==u.test(p[m].$viewValue)&&s.push("O campo "+g+" está com uma data inválida")}}if(s.length>0)c.warning(s.join("
"));else{if(a.id)var h=e.data.put(),b="edit";else var h=e.$parent.resource.post(e.data),b="new";h.then(function(){void 0!=e.doAfterSave&&"function"==typeof e.doAfterSave?e.doAfterSave(resp,b):l.go(l.current.name.replace(".edit",".list").replace(".new",".list"),{filter:e.getFilter()})},function(e){function t(e){for(var t in i.headers.fields){var a=i.headers.fields[t];if(a.name==e)return a.label}}var a=[];if(422==e.status)if("CANT_SAVE_MODEL"==e.data.error.code)a.push(e.data.error.message);else if(e.data.error.details){var n=e.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"};_.each(n,function(e,i){var n=t(i),l=o[e].replace("%s",n);a.push(l)})}else a.push(e.data.error.message);c.warning(a.join("
"))})}}},e.cancel=function(){l.go(l.current.name.replace(".edit",".list").replace(".new",".list"),{filter:e.getFilter()})},e.autocompleteModels={},e.autocompleteAdd=function(e){},e._autocomplete=function(t,a,i){var n=[],o=s.defer();if(t.autocomplete_dependencies.length>0){var l=t.autocomplete_dependencies;for(var r in l){var c=l[r];if(void 0==e.data[c.field]||null==e.data[c.field]){var d="Selecione antes o(a) "+c.label,u=[];return u.push({id:null,label:d}),o.resolve(u),o.promise}n[c.field]=e.data[c.field]}}if(a=a.trim(),(0==a.length||1==t.customOptions.select)&&(a="[blank]"),void 0!==t.customOptions.general)e.resource.customGET("general/autocomplete/"+t.customOptions.general+"/"+a,n).then(function(e){t.quickAdd===!0&&"[blank]"!=a&&e.push({id:-1,label:"Adicionar novo: "+a}),o.resolve(e)},function(){return o.reject()});else if(void 0==t.customOptions.list){if(i)var f="details/"+i+"/autocomplete/"+t.name+"/"+a;else var f="autocomplete/"+t.name+"/"+a;1==t.customOptions.select?n.limit=0:n.limit=20,e.resource.customGET(f,n).then(function(e){1==t.customOptions.select&&e.unshift({id:null,label:"--- Selecione ---"}),t.quickAdd===!0&&"[blank]"!=a&&e.push({id:-1,label:"Adicionar novo: "+a}),o.resolve(e)},function(){return o.reject()})}else{var p=angular.copy(t.customOptions.list)||[];1==t.customOptions.select&&p.unshift({id:null,label:"--- Selecione ---"}),o.resolve(p)}return o.promise},e.autocomplete=function(e,t){return this._autocomplete(e,t,null)},e.autocompleteDetail=function(e,t,a){return this._autocomplete(t,a,e)},e.doafterAutoCompleteSelect={},e._autocompleteSelect=function(t,a,n,o){var l=o?this.detail_data:this.data;if(void 0==l&&(l={}),null!=t.id&&"integer"!=typeof t.id||"integer"==typeof t.id&&t.id>0)l[this.field.name]=t.id;else{if(null!=t.id)return l[this.field.name+".label"]=null,!1;l[this.field.name]=l[this.field.name+".label"]=null}"function"==typeof e.doafterAutoCompleteSelect[this.field.name]&&e.doafterAutoCompleteSelect[this.field.name].call(this,l,t,a,n),o?this.detail_data=l:this.data=l;var r=this.field;i(function(){jQuery("#"+r.name).trigger("keyup")})},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)},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);e.headers.parent_route?e.headers.parent_route:e.headers.route.toLowerCase();t.route=i?n:e.headers.route+t.fixedRoute,t.id=i?i:null,f.createCRUDModal(t,null,"CRUDEditDetailController")},e.deleteDetail=function(e,a){var i=t.all(e);i.customDELETE(a.id).then(function(){r.$broadcast("refreshGRID"),r.$broadcast("data-grid-updated",{type:e.split("/").pop()})},function(e){c.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,f.createCRUDModal(n).then(function(t){t["new"]=!0,e.data[a].push(t)})}else{var o={},l=e.headers[t][a].fields;for(var r in l)"boolean"!=l[r].type?o[l[r].name]=null:o[l[r].name]=!1;o["new"]=!0,e.data[a].push(o),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,f.createCRUDModal(n,i).then(function(t){e.data[a][e.data[a].indexOf(i)]=t})},e.deleteDetailData=function(e,t){window.confirm("Deseja realmente excluir esse item?")&&this.data[t].splice(this.data[t].indexOf(e),1)}}])}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDEditDetailController",["$scope","Restangular","$http","$stateParams","$timeout","headers","$rootScope","$modalInstance","$q","ngToast","Upload",function(e,t,a,i,n,o,l,r,s,c,d){e.data={},e.headers=o,e.resource=t.all(o.route),e.autocompleteModels={},e.doafterAutoCompleteSelect={},e.$http=a,o.modal_id&&l.$emit("open:"+o.modal_id,e),e.datepickers={},e.datepickerToggle=function(t){void 0==e.datepickers[t]&&(e.datepickers[t]=!1),e.datepickers[t]=!e.datepickers[t]};for(var u in e.headers.fields){var f=e.headers.fields[u];"boolean"==f.type&&(e.data[f.name]=!1)}if(o.id)e.resource.customGET(o.id).then(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 o=new Date(t[i.name]);o.setHours(o.getHours()+o.getTimezoneOffset()/60),t[i.name]=o}i.customOptions&&void 0!=i.customOptions.list&&i.customOptions.list.forEach(function(e){e.id==t[i.name]&&(t[i.name+".label"]=e.label)}),"password"==i.type&&(i.notnull=!1)}e.data=t,n(function(){e.$broadcast("setProgressFile")}),e.$emit("data-loaded-detail")});else{n(function(){e.$emit("data-new-detail")},50);for(var u in e.headers.fields){var f=e.headers.fields[u];"boolean"==f.type&&(e.data[f.name]=f.customOptions["default"]?f.customOptions["default"]:!1)}}n(function(){e.submit=function(){function t(){if(e.data.id)var t=e.resource.customPUT(e.data,e.data.id),n="edit";else var t=e.resource.customPOST(e.data,i.id),n="new";t.then(function(t){function a(){l.$broadcast("refreshGRID"),r.dismiss("success")}e.$emit("after save",a,t,n),e.$$listeners["after save"]||a()},function(t){function i(e){for(var t in a.headers.fields){var i=a.headers.fields[t];if(i.name==e)return i.label}}var n=[];if(422==t.status)if("CANT_SAVE_MODEL"==t.data.error.code)n.push(t.data.error.message);else if(t.data.error.details){var o=t.data.error.details.codes,l={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(o,function(e,t){var a=i(t);"string"==typeof e&&(e=[e]),_.each(e,function(e,t){var i=l[e].replace("%s",a);n.push(i)})})}else n.push(t.data.error.message);c.warning(n.join("
")),e.$emit("error save",t)})}var a=this,n={},o=a.data;if(_.each(a.headers.fields,function(e,t){"password"==e.type&&0!=e.name.indexOf("confirm")&&o["confirm_"+e.name]!=o[e.name]&&(n.password='Os campos "'+e.label+'" e "Confirmar '+e.label+'" não são iguais')}),Object.keys(n).length>0){var s=new Array;_.each(n,function(e,t){s.push(e)}),c.warning(s.join("
"))}else this.crudForm.$valid&&(e.$emit("before save",t),e.$$listeners["before save"]||t())},e.cancel=function(){r.dismiss("success")},e._upload=function(e,t){var a=l.appSettings.API_URL;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/"+e.customOptions.file.container+"/upload":void 0!=e.customOptions.file.url&&void 0!=e.customOptions.file.container&&(a+="upload/"+e.customOptions.file.container+"/"+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=l.appSettings.API_URL+"upload/"+t.customOptions.file.container+"/download/"+e.data[t.name];else var i=l.appSettings.API_URL+e.module+"/download/"+t.name+"/"+a;e._download(i,t,e.data)},e.downloadDetail=function(t,a,i,n){if(void 0!=a.customOptions.file.container)var o=l.appSettings.API_URL+"upload/"+a.customOptions.file.container+"/download/"+n[a.name];else var o=l.appSettings.API_URL+e.module+"/details/"+t+"/download/"+a.name+"/"+i;e._download(o,a,n)},e._download=function(t,a,i){this.$http({method:"GET",url:t,responseType:"arraybuffer"}).success(function(t,n,o){if(o=o(),void 0!=a.customOptions.file.container)var l=i[a.name];else var l=o["content-disposition"].split(";")[1].split("=")[1].split('"')[1];var r=o["content-type"],s=new Blob([t],{type:r});e.downloadFile(s,l)})},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(o){}},e._autocomplete=function(t,a,i){var n=[],o=s.defer();if(t.autocomplete_dependencies.length>0){var l=t.autocomplete_dependencies;for(var r in l){var c=l[r];if(void 0==e.data[c.field]||null==e.data[c.field]){var d="Selecione o "+c.label,u=[];return u.push({id:null,label:d}),o.resolve(u),o.promise}e.data[c.field].id?n[c.field]=e.data[c.field].id:n[c.field]=e.data[c.field]}}if(a=a.trim(),(0==a.length||1==t.customOptions.select)&&(a="[blank]"),void 0==t.customOptions.list){var f="autocomplete/"+t.name+"/"+a;1==t.customOptions.select?n.limit=0:n.limit=20,e.resource.customGET(f,n).then(function(e){1==t.customOptions.select&&e.unshift({id:null,label:"--- Selecione ---"}),t.quickAdd===!0&&"[blank]"!=a&&e.push({id:null,label:"Adicionar novo: "+a}),o.resolve(e)},function(){return o.reject()})}else{var p=angular.copy(t.customOptions.list)||[];1==t.customOptions.select&&p.unshift({id:null,label:"--- Selecione ---"}),o.resolve(p)}return o.promise},e._autocompleteSelect=function(t,a,i,o){if(null!=t.id&&"integer"!=typeof t.id||"integer"==typeof t.id&&t.id>0)this.data[this.field.name]=t.id;else{if(null!=t.id)return this.data[this.field.name+".label"]=null,!1;this.data[this.field.name]=this.data[this.field.name+".label"]=null}"function"==typeof e.doafterAutoCompleteSelect[this.field.name]&&e.doafterAutoCompleteSelect[this.field.name].call(this,this.data,t,a,i);var l=this.field;n(function(){jQuery("#"+l.name).trigger("keyup")})},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)}},500)}])}(),angular.module("letsAngular").run(["$templateCache",function(e){e.put("lets/views/crud/crud-detail-list.html",'
{{field.label}}{{field.label}}Ações
Nenhum dado cadastrado.
'),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",'
Informações Principais
Informações Principais
'),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$
  • A data informada é inválida.
  • O horário informado é inválido.
{{f.progress + \'%\'}} {{f.name}} {{f.newName}}
{{column.label}}
{{data[column.name]}}
'); +!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","thatisuday.dropzone","swangular","angularjs-dropdown-multiselect","daterangepicker"]);a.config(t),a.provider("headers",e),t.$inject=["$stateProvider","$httpProvider"]}(),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,o){return i._createModal({animation:!0,templateUrl:o||"lets/views/crud/crud-modal.html",controller:n||"CRUDFormModalController",resolve:{headers:function(){return e},data:function(){try{var e=angular.copy(a)}catch(i){var e=t.extend({},a)}return e}},size:"lg",backdrop:"static",keyboard:!1})},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 o in i){var l=t.$error[i[o]];for(var r in l){var s=l[r].$options.fieldInfo.label;"required"==i[o]?a.push("O campo "+s+" é obrigatório"):"date"==i[o]&&0==n.test(l[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,o,l,r){var s=o.API_URL,d=this;d.updateLocalStorage=function(e,t){var a=d.getUser();a[e]=t,d.setUserInfo(a)},d.setUserLb=function(e){t.setUser(e.id,e.userId,e.user),t.rememberMe=!0,t.save()},d.setUserInfo=function(e){window.localStorage.user=angular.toJson(e)},d.getUser=function(){return window.localStorage.user?JSON.parse(window.localStorage.user):!1},d.isAuthenticated=function(){return null!=t.currentUserId},d.authenticate=function(e){return n.authenticate(e).then(function(e){var t={accessToken:e.access_token};return l.post(s+"users/facebook/token",t)}).then(function(e){var t={id:e.data.id,userId:e.data.user.id,user:e.data.user};d.setUserLb(t),d.setUserInfo(e.data.user),d.removeSatellizer(),i.go("main.search")})["catch"](function(e){})},d.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")})},d.getCurrentUserId=function(){return t.currentUserId},d.getCurrentUserToken=function(){return t.accessTokenId},d.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,o,l,r){var s=0,d="";if(n.setColors)n.setColors=JSON.parse(n.setColors),n.setColors.forEach(function(t){0==s?(d+='
',s++):3==s?(d+='
',s=0):(d+='',s++)},this);else for(var c in e)0==s?(d+='
',s++):3==s?(d+='
',s=0):(d+='',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),o.replaceWith(f),d=b+d,p=angular.element(d),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"===o[0].tagName?(d=b+d,p=angular.element(d),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?o[0].style.backgroundColor=t:o.val(t)}),n.$watch("ngModel",function(e,t){var a=e;void 0!=a&&void 0!==n.colorMe&&"true"===n.colorMe&&(o[0].style.backgroundColor=a,o[0].value="")}),angular.element(document.body).append(p),o.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),o.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,o=a.getBoundingClientRect().height;n+=i.pageYOffset,p.removeClass("hide"),p[0].style.top=n+o+"px",p[0].style.left=a.getBoundingClientRect().left+"px",e.stopPropagation()}),t(u)(n)):(d=h+d,p=t(d)(n),o.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;ti;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 o="["+i.toUpperCase()+"]";if(-1!==t.indexOf(o)){var l=t.split(o),r="",s=l.length;l.forEach(function(t,o){r+=t,s-1>o&&(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(o,l){moment.locale("pt-br");var r=angular.extend(t.$new(),l);e(o).then(function(e){var t=a($("
"+e+"
"))(r),o=function(){r.$$phase?i(o):(n._printHTML(t.html()),r.$destroy())};o()})},{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 o=a;"id"!==a&&(o="label"),"label"===o&&t&&i===t.relation?n.label=e[i][t.label]:n[o]=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,o,l){var r=t.slice(0),s=Object.keys(l).length,d=e._getFilledFilterAttr(a,n),c="neutral";d.checkboxes.forEach(function(e){n[e].length>o[e].length?c="add":n[e].lengtha[t]?1:0}):e},e.getMinMaxValues=function(e,t,a,i,n,o,l){var r={x:l[0][t],y:l[0][n]},s={x:l[0][t],y:l[0][n]};return l.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(o,"day").format("MM/DD/YYYY")),s.y=new Date(moment(s.y).add(o,"day").format("MM/DD/YYYY"))):(r.y-=o,s.y+=o),{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){return{restrict:"A",scope:!0,link:function(t,a,i){t.defaultProgress=0,t.alreadySent=!1;var n=!0;t.$on("setProgressFile",function(){void 0!=t.data[t.field.name]&&null!=t.data[t.field.name]&&t.fileName&&"fileName"!=t.fileName&&(t.defaultProgress=100,t.alreadySent=!0)}),t.pushName=function(){e(function(){if(document.getElementsByClassName("dz-filename")[0]&&n){n=!1,document.getElementsByClassName("dropzone")[0].style.width="192px",document.getElementsByClassName("file-preview")[0]&&(document.getElementsByClassName("file-preview")[0].style.display="none"),document.getElementsByName("temp_filename")[0].value=document.getElementsByClassName("dz-filename")[0].firstElementChild.innerText;var e=i.find('input[type="hidden"]');e.controller("ngModel").$setViewValue(document.getElementsByName("temp_filename")[0].value)}})},t.remove=function(){t.alreadySent=!1;var e=i.find('input[type="hidden"]');document.getElementsByName("temp_filename")[0].value=null,e.controller("ngModel").$setViewValue(null)},t.upload=function(a,n){t.f=a,t.errFile=n&&n[0],a&&(a.upload=t._upload(t.field,a),a.upload.then(function(n,o){t.$emit("upload-complete",n),e(function(){if(a.result=n.data,i.$$element)var e=i.$$element.find('input[type="hidden"]');else var e=i.find('input[type="hidden"]');a.newName=n.data.result.files.file[0].name,e.controller("ngModel").$setViewValue(a.newName)})},function(e){e.status>0&&(t.errorMsg=e.status+": "+e.data),t.$emit("upload-error",e)},function(e){a.progress=Math.min(100,parseInt(100*e.loaded/e.total))}))}}}}angular.module("letsAngular").directive("fwUpload",e),e.$inject=["$timeout"]}(),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";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,o,l){t(function(){n||(n="[blank]");var r=l?"general/":"";e.resource=a.all(e.route()),e.resource.customGET(r+"autocomplete/"+o+"/"+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,o=a.customOptions.general?!0:!1;if(!i.initMultiSelect){var l=i.scope();i.initMultiSelect=!0,e.makeRequestAutocomplete(l,"[blank]",n,o),i.parent().find(".dropdown-header").append(''),l.$watch("input.searchFilter",e._debounce(function(t){e.makeRequestAutocomplete(l,t,n,o)})),l.texts.buttonDefaultText="Selecione "+a.label,l.texts.searchPlaceholder="Buscar "+a.label,l.texts.dynamicButtonTextSuffix="selecionado(s)",l.externalEvents.onItemSelect=e.onItemSelect,l.externalEvents.onSelectionChanged=e.changedMultiSelect,l.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,o,l,r){var s=o.attr("fw-data");if(t.field&&t.field.customOptions&&"object"==typeof t.field.customOptions&&!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 d=t.detail_key;t.field&&t.field.autocomplete!==!1&&(t.autocomplete=function(e,a){return t.autocompleteDetail(d,e,a)},t.autocompleteSelect=function(e,a,i){return t.autocompleteDetailSelect(d,e,a,i)}),t.field&&t.field.customOptions&&void 0!=t.field.customOptions.file&&(t.download=function(e,a){return t.downloadDetail(d,e,a,t.data)})}if(t.field&&t.field.customOptions&&void 0!=t.field.customOptions.cep)o.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(t.field&&t.field.customOptions&&void 0!=t.field.customOptions.multiple&&1==t.field.customOptions.multiple){a(o.contents())(t)}i(o).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.openDate=function(e){$("input#"+e.name).click()},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,o,l){if(l||(l=n.controller("ngModel")),a.field&&"date"==a.field.type)n.mask("99/99/9999");else if(a.field&&void 0!=a.field.customOptions&&void 0!=a.field.customOptions.cpf&&null!=a.field.customOptions.cpf)n.mask("999.999.999-99");else if(void 0!=a.field.customOptions&&void 0!=a.field.customOptions.cnpj)n.mask("99.999.999/9999-99");else if(void 0!=a.field.customOptions&&void 0!=a.field.customOptions.customMask)n.mask(a.field.customOptions.customMask);else if(void 0!=a.field.customOptions&&"float"==a.field.type)void 0!=a.field.customOptions&&void 0!=a.field.customOptions.currency&&(n.mask("#.##0,00",{reverse:!0}),l.$parsers.unshift(function(e){return parseFloat(n.cleanVal(),10)/100}),l.$formatters.unshift(function(e){return n.masked(e?parseFloat(e).toFixed(2):null)}));else if(void 0!=a.field.customOptions&&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&&void 0!=a.field.customOptions.telefone){var d=function(e){return 11===e.replace(/\D/g,"").length?"(00) 00000-0000":"(00) 0000-00009"},c={onKeyPress:function(e,t,a,i){a.mask(d.apply({},arguments),i)}};t(function(){n.mask(d,c)},100)}else void 0!=a.field.customOptions&&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,o){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 o=t[a.name],o=o.toFixed(2).split(".");return o[0]="R$ "+o[0].split(/(?=(?:...)*$)/).join("."),o.join(",")}return t[a.name]}if("custom"==a.type){var l=a.toString({attributes:t});return l&&l[0]&&l[0].outerHTML?n.trustAsHtml(l[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 o=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(o),o.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 o="dd/MM/yyyy";void 0!==t.field.customOptions.monthpicker&&(n.datepickerMode="'month'",n.minMode="month",o="MM/yyyy"),a.find("input").attr("datepicker-popup",o),a.find("input").blur(function(){moment(this.value,o).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(){"use strict";function e(e,t){var a="vm";return{restrict:"A",require:"?ngModel",scope:!0,terminal:!0,priority:1,link:{post:function(t,a,i,n){$(a).find("input").controller();try{a.addClass("form-control");var o=JSON.parse(i.field),l=!0;"object"==typeof o.filter&&o.filter.range===!0&&o.filter._edit===!0&&(l=!1);var r=moment().startOf("month"),s=moment(),d=l?"{":"{date: {startDate: "+r+", endDate: "+s+" }, ",c=d+" minYear: 1901, maxYear: parseInt(moment().format('YYYY'), 10), applyButtonClasses: 'btn-primary', cancelButtonClasses: 'btn-default', showDropdowns: false, singleDatePicker:"+l+", locale: { format: 'DD/MM/YYYY', separator: ' - ', applyLabel: 'Aplicar', cancelLabel: 'Cancelar', daysOfWeek: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'], monthNames: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'], }, }";l?a.attr("placeholder","DD/MM/YYYY"):a.attr("placeholder","DD/MM/YYYY - DD/MM/YYYY"),a.attr("options",c.toString()),a.removeAttr("new-date-picker")}catch(u){console.error(u)}a.on("show.daterangepicker",function(e,t){l||t.startDate||t.endDate||(t.setStartDate(r),t.setEndDate(s))}),e(a)(t)}},controller:["$scope",function(e){setTimeout(function(){console.log(e)},100)}],controllerAs:a}}angular.module("letsAngular").directive("newDatePicker",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,o){var l=o[0],r=o[1];l.ready().then(function(){["dataReady","change","blur","saveSnapshot"].forEach(function(e){l.onCKEvent(e,function(){r.$setViewValue(l.instance.getData()||"")})}),l.instance.setReadOnly(!!n.readonly),n.$observe("readonly",function(e){l.instance.setReadOnly(!!e)}),i(function(){e(n.ready)(t)})}),r.$render=function(){l.ready().then(function(){l.instance.setData(r.$viewValue||"",{noSnapshot:!0,callback:function(){l.instance.fire("updateSnapshot")}})})}}}}function a(e,t,a,n,o){var l,r=n(a.ckeditor)(e)||{},s=t[0],d=o.defer();l=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(){o.apply(null,e)})}function o(){var t=arguments;e.$apply(function(){a.apply(null,t)})}return l.on(t,n),function(){l.removeListener(t,o)}},this.onCKEvent("instanceReady",function(){d.resolve(!0)}),this.ready=function(){return d.promise},e.$on("$destroy",function(){d.promise.then(function(){l.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(),o=n.chart_settings,l=i.crudChartData();i.key=n.key,i.d3chartUpdate=!1;var r=t.getMinMaxValues(o.xType,o.xLabel,o.xOffset,o.yType,o.yLabel,o.yOffset,l),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,l),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(){var e=i.val(),a=e+" ";i.controller("ngModel").$setViewValue(a),t(function(){i.controller("ngModel").$setViewValue(e)})};a.find("button").click(n),i.click(n),i.keyup(function(){""==this.value.trim()&&(i.scope().data[i.attr("name")]=null)})},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,o){var l=i.find(":input").val().split(" "),r="/^("+l[0]+")";l.splice(0,1),l.forEach(function(e){r+="(?=.*"+e+")"}),r+=".*/i";var s='{"limit": 5,"where":{"'+o+'":{"regexp":"'+r+'"}}}',d=t.appSettings.API_URL+e+"?filter="+s,c=t.appSettings.API_URL+e+"/crudGET/";a.get(d).then(function(e){n.autoCompleteTableData2=[],e.data.forEach(function(e){a.get(c+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,o,l,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)})}],link:function(o,s,d){function c(){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(d.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 o={fromRaw:e.toString,toRaw:function(e,t){return"down"}};n.sortable=!1;var l=i.Cell.extend({className:"custom-cell",formatter:o});l.initialize=function(){i.Cell.prototype.initialize.apply(this,arguments)},l.render=function(){this.$el.empty(),this.$el.data("model",this.model);var e=o.fromRaw(this.model);return this.$el.append(e),this.delegateEvents(),this},n.cell=i.Cell.extend(l)}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 d="DD/MM/YYYY",c="YYYY/M/D",u=!0;void 0!==e.customOptions.monthpicker&&(d="MM/YYYY"),e.customOptions.timestamp&&(c="YYYY/M/D HH:mm:ss.SSS",u=!1),n.cell=i.Extension.MomentCell.extend({modelFormat:c,displayLang:"pt-br",displayFormat:d,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 l=i.Cell.extend({className:"text-right btn-column"+(1==d.tab?" detail":""),template:function(){var e=[];if(d.tab)if(d.settings){if(d.settings.edit){var a=t('');a.attr("data-route",d.url),e.push(a)}if(d.settings["delete"]){var i=t('');i.attr("data-route",d.url),e.push(i)}}else{var i=t('');i.attr("data-route",d.url),e.push(i)}else d.settings.edit&&e.push(t('')),d.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();d.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("Deseja realmente excluir esse registro?");if(t){var a=angular.element(this).scope();d.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("Deseja realmente excluir esse registro?");if(a){var i=angular.element(this).scope(),n=t(this).attr("data-route");d.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}});(d.settings.edit||d.settings["delete"])&&a.push({name:"actions",label:"Ações",sortable:!1,cell:l}),o.$parent.app.helpers.isScreen("xs")&&a.splice(3,1);var r=[];1==d.tab&&r.push("detail"),void 0==d.settings||d.settings.edit||r.push("cant-edit");var s=i.Row.extend({className:r.join(" ")}),c="table table-striped table-editable no-margin mb-sm";d.tableClass&&(c+=" "+d.tableClass);var u=new i.Grid({row:s,columns:a,collection:e,className:c}),f=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"}}});o.$el.find(".table-container").html("").append(u.render().$el).append(f.render().$el),setTimeout(function(){angular.element(f.render().$el).click(function(){window.scrollTo({top:100,behavior:"smooth"})})},0),o.$broadcast("refreshGRID",!0)}var d=o.crudListSettings();d.route=n.API_URL+d.url,o.route=d.route,i.InputCellEditor.prototype.attributes["class"]="form-control input-sm";var c=a.Model.extend({}),u={model:c,url:d.route+(d.pagerGeneral?"/pagerGeneral":"/pager"),state:{pageSize:20},mode:"server",parseRecords:function(e,t){return o.$el[0].parseRecords&&"function"==typeof o.$el[0].parseRecords?o.$el[0].parseRecords(e.data):e.data},parseState:function(e,a,i,n){return l(function(){var a=t("
    ");a.append(t("
  • ").html("Registros na página: "+e.total_entries+" / "+e.total_count)),o.$el.find(".table-container .backgrid-paginator ul.total-records").remove(),o.$el.find(".table-container .backgrid-paginator").append(a)}),o.$parent.totalPager=e.total_count,{totalRecords:e.total_count}}};d.filterScope&&(u.queryParams={scope:d.filterScope}),d.sort&&(u.state.sortKey=d.sort.sortKey,d.sort.order&&"desc"==d.sort.order&&(u.state.order=1));var f=a.PageableCollection.extend(u),p=new f;o.pageableCRUDModel=p;var m=angular.copy(p.fetch);p.fetch=function(t,a,i){l(function(){i&&(p.state.currentPage=1);var n=o.$el.attr("grid"),l=$('div[crud-filter][grid="'+n+'"] input').scope();if(l||(l={}),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&&(l.data.p=s.p,p.state.currentPage=parseInt(s.p)),s.q)l.data.q=s.q;else{l=l||{};var d=!1;Object.keys(s).forEach(function(e){if(e.split("_label").length>1)l.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?(l.data[e+"_"+t]=moment(s[e][t],"DD/MM/YYYY").toDate(),"ini"==t&&(l.data[e]=l.data[e]?l.data[e]:{},l.data[e].startDate=moment(s[e][t],"DD/MM/YYYY").toDate()),"fim"==t&&(l.data[e]=l.data[e]?l.data[e]:{},l.data[e].endDate=moment(s[e][t],"DD/MM/YYYY").toDate())):s[e][t].id&&s[e][t].label?l.data[e]=s[e]:(l.data[e]=l.data[e]||{},l.data[e][t]=s[e][t]);else l.data[e]=s[e];"p"!=e&&(d=!0)}),l.data.showBusca=d}l.filterData(!1)}}else if("main"==n){var c=[];if(l.objFilter&&l.objFilter.data.q&&c.push("q="+l.objFilter.data.q),l.objFilter&&l.objFilter.data.filter&&Object.keys(l.objFilter.data.filter).length>0)for(var u in l.objFilter.data.filter)if("object"==typeof l.objFilter.data.filter[u]){if(l.objFilter.data.filter[u].ini&&c.push(u+"_ini="+l.objFilter.data.filter[u].ini),l.objFilter.data.filter[u].fim&&c.push(u+"_fim="+l.objFilter.data.filter[u].fim),!l.objFilter.data.filter[u].ini&&!l.objFilter.data.filter[u].fim){var f=l.objFilter.data.filter[u];c.push(u+"="+JSON.stringify(f))}}else"p"!=u&&c.push(u+"="+l.objFilter.data.filter[u]);p.state&&p.state.currentPage&&1!=p.state.currentPage&&c.push("p="+p.state.currentPage);var g=c.join("&");r.transitionTo(r.$current.name,{filter:g},{location:!0,inherit:!0,relative:r.$current,notify:!1})}l&&l.objFilter&&l.objFilter.data.q&&(t=t||{data:{}},t.data=t.data||{},t.data.q=l.objFilter.data.q,l.objFilter.data.p&&a&&(t.data.page=l.objFilter.data.p,p.state.currentPage=parseInt(l.objFilter.data.p))),l.objFilter&&l.objFilter.data.filter&&Object.keys(l.objFilter.data.filter).length>0&&(t=t||{data:{}},t.data=t.data||{},t.data.filter=l.objFilter.data.filter,l.objFilter.data.filter.p&&a&&(t.data.page=l.objFilter.data.filter.p,p.state.currentPage=parseInt(l.objFilter.data.filter.p))),m.call(p,t)})},s(p)}o.$el=s;var u=o.$parent.$watch("headers",function(e,t){if(null!=e){var a=o.crudListSettings();if(1==a.tab)var i=o.$parent.$watch("data",function(e,t){void 0!=e.id&&(c(),i(),u())});else c(),u()}})}}}angular.module("letsAngular").directive("crudList",e),e.$inject=["$window","jQuery","Backbone","Backgrid","appSettings","fwObjectService","$timeout","$state"]}(),function(){"use strict";function e(e,t,a){return{replace:!1,link:function(i,n){for(var o in i.headers.fields){var l=i.headers.fields[o];l.customOptions&&l.customOptions.file&&(i.dzOptions={url:a.API_URL+"upload/"+l.customOptions.file.container+"/upload",acceptedFiles:l.customOptions.file.acceptedFiles,maxFilesize:"25",maxFiles:"1",uploadMultiple:!1,addRemoveLinks:!0})}i.dzMethods={},i.removeNewFile=function(){i.dzMethods.removeFile(i.newFile)},e(n).on("click",".button-new",function(){var t=e(this).attr("detail"),a=e(this).attr("origin"),n="true"==e(this).attr("form-modal");i.newDetailData(a,t,n)}),t(function(){n.find(".tab-group .nav-tabs li:first").find("a").click(),n.find(':input[type!="hidden"]:first').focus()},500),$(n).parsley({priorityEnabled:!1,errorsContainer:function(e){return e.$element.closest(".input-container")}})}}}angular.module("letsAngular").directive("crudForm",e),e.$inject=["jQuery","$timeout","appSettings"]}(),function(){"use strict";function e(e,t,a,i){return{templateUrl:"lets/views/crud/crud-filter.html",replace:!0,scope:{fields:"&",route:"&",search:"&",clearButton:"=clearButton"},controller:["$scope",function(e){}],link:function(n,o){n.data={},n.showBuscaAvancada=!1;var l;n.fieldsFilter=[],n.startFilters=function(){l=angular.copy(n.fields()),n.fieldsFilter=[],l=l.filter(function(e){return e.filter}),l.forEach(function(e,t){if(e.filter){if(e.disabled=!1,e.notnull=!1,e.name=e.name,void 0!=e.customOptions&&e.customOptions.file&&delete e.customOptions.file,e.customOptions.multiselect&&(e.type="multiselect",e.autocomplete=!1),"text"==e.type)e.type="string";else if("boolean"==e.type)e.type="number",e.autocomplete=!0,e.customOptions={list:[{id:"false",label:e.customOptions.statusFalseText},{id:"true",label:e.customOptions.statusTrueText}],select:!0};else if("olddate"==e.type){if("object"==typeof e.filter&&e.filter.range===!0){var a=angular.copy(e);a.name+="_ini",a.label+=" (Início)",n.fieldsFilter.push(a);var i=angular.copy(e);return i.name+="_fim",i.label+=" (Término)",void n.fieldsFilter.push(i)}}else if("date"==e.type){if(e.filter._edit=!0,"object"==typeof e.filter&&e.filter.range===!0)return void n.fieldsFilter.push(e)}else if(("number"==e.type||"integer"==e.type||"float"==e.type||"bigint"==e.type)&&"object"==typeof e.filter&&e.filter.range===!0){var a=angular.copy(e);a.name+="_ini",a.label+=" (Início)",n.fieldsFilter.push(a);var i=angular.copy(e);return i.name+="_fim",i.label+=" (Término)",void n.fieldsFilter.push(i)}n.fieldsFilter.push(e)}}),n.fieldsFilter=n.fieldsFilter.sort(function(e,t){var a=e.filter.sequence||0,i=t.filter.sequence||0;return a-i}),setTimeout(function(){n.$emit("filter-init",n),n.$broadcast("filter-init",n)},500)},n.autocomplete=function(a,i){n.$emit("before-filter-autocomplete",n),n.resource=t.all(n.route());var o=[],l=e.defer();if(a.autocomplete_dependencies.length>0){var r=a.autocomplete_dependencies;for(var s in r){var d=r[s];if(void 0==n.data[d.field]||null==n.data[d.field]||"null"==n.data[d.field]){var c="Selecione antes o(a) "+d.label,u=[];return u.push({id:null,label:c}),l.resolve(u),l.promise}o[d.field]=n.data[d.field]}}if(i=i.trim(),(0==i.length||1==a.customOptions.select)&&(i="[blank]"),void 0!==a.customOptions.general)n.resource.customGET("general/autocomplete/"+a.customOptions.general+"/"+i,o).then(function(e){l.resolve(e)},function(){return l.reject()});else if(void 0==a.customOptions.list){var f="autocomplete/"+a.name+"/"+i;1==a.customOptions.select?o.limit=0:o.limit=20,n.resource.customGET(f,o).then(function(e){e.unshift({id:"null",label:"[Em Branco]"}),e.unshift({id:null,label:"--- Selecione ---"}),l.resolve(e)},function(){return l.reject()})}else{var p=angular.copy(a.customOptions.list)||[];1==a.customOptions.select&&(a.customOptions.onlyList||p.unshift({id:"null",label:"[Em Branco]"}),a.customOptions.required||p.unshift({id:null,label:"--- Selecione ---"})),l.resolve(p)}return l.promise},n.autocompleteSelect=function(e,t,i){n.$emit("after-filter-autocomplete",{scope:n,name:this.field.name,value:e});var o=this.data;if(void 0==o&&(o={}),null!=e.id&&"integer"!=typeof e.id||"integer"==typeof e.id&&e.id>0)o[this.field.name]=e.id;else{if(null!=e.id)return o[this.field.name+".label"]=null,!1;o[this.field.name]=o[this.field.name+".label"]=null}this.data=o;var l=this.field;a(function(){jQuery("#"+l.name).trigger("keyup")})},n.filterData=function(e){n.objFilter=void 0;var t={};n.data.showBuscaAvancada&&(n.showBuscaAvancada=angular.copy(n.data.showBuscaAvancada),delete n.data.showBuscaAvancada),n.showBuscaAvancada||n.data.showBusca?(l.forEach(function(e,a){if("object"==typeof e.filter&&e.filter.range===!0){var i={};n.data[e.name]&&("date"==e.type?(i.ini=n.data[e.name].startDate,i.fim=n.data[e.name].endDate,i.ini=n.getDateFormated(i.ini),i.fim=n.getDateFormated(i.fim),Object.keys(i).length>0&&(delete t[e.name],t[e.name]=i)):"olddate"==e.type&&(n.data[e.name+"_ini"]&&(i.ini=n.data[e.name+"_ini"],"date"==e.type&&(i.ini=n.getDateFormated(i.ini))),n.data[e.name+"_fim"]&&(i.fim=n.data[e.name+"_fim"],"date"==e.type&&(i.fim=n.getDateFormated(i.fim))),Object.keys(i).length>0&&(t[e.name]=i)))}else n.data[e.name]&&(t[e.name]=n.data[e.name],e.customOptions&&e.customOptions.telefone?t[e.name]=n.data[e.name].replace(/\D/g,""):"olddate"==e.type?t[e.name]=n.getDateFormated(t[e.name]):"date"==e.type&&e.filter&&1!=e.filter.range?t[e.name]=n.getDateFormated(t[e.name]):e.autocomplete&&!e.customOptions.multiselect?t[e.name+"_label"]=n.data[e.name+".label"].label:e.autocomplete&&e.customOptions.multiselect&&(t[e.name]=n.data[e.name]))}),n.data.q=null,n.objFilter={data:{filter:t}}):(t.q=n.data.q,t.p=n.data.p,n.objFilter={data:t}),e&&i.$broadcast("refreshGRID",!1,!0)},n.openBuscaAvancada=function(){n.showBuscaAvancada=!n.showBuscaAvancada},n.clearBusca=function(){Object.keys(n.data).forEach(function(e){n.data[e]=null}),n.filterData(!0)},n.getDateFormated=function(e){return moment(e).format("DD/MM/YYYY")},n.startFilters(),n.$on("refresh-fields",function(e,t){n.startFilters()}),"fixed"==n.search()&&(n.showBuscaAvancada=!0,n.hideInputSearch=!0)}}}angular.module("letsAngular").directive("crudFilter",e),e.$inject=["$q","Restangular","$timeout","$rootScope"]}(),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 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";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","$stateParams","$rootScope","headers","swangular","ngToast",function(e,t,a,i,n,o,l,r,s,d){function c(){var t=angular.copy(r.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=[],o=t.slice(1);return e.forEach(function(e){n.append(e[t[0]])}),i(n,o)}var n=e[t[0]],o=t.slice(1),o=t.slice(1);return i(n,o)}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 o=Object.keys(e);if(Array.isArray(e[o[0]])){var l=e[o[0]];l.forEach(function(e){n([e],t,a)})}}a=""})}function o(e){var i=e.fields.filter(t).map(a);if(e.tabs)for(var n in e.tabs){var l=o(e.tabs[n]);if(l){var r={};r[n]=l,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=o(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 l(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 r(e){var t={};e=e.split("&");for(var a=0;a',o+='",o+="
",b.push("m_"+r+i),h.push(a.join("#")+"#"+i)}}else i+1>0||(t.push(e.real_name),a.push(i)),o+=c(n,t,a)}),o}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 d.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=o(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+=c(m[v],[],[])}g+="
",s.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){s.swal({html:"Por favor aguarde, estamos buscando os dados.",allowOutsideClick:!1,allowEscapeKey:!1,onOpen:function(){s.showLoading()}});var a=h.filter(function(e,a){return t.value[a]}),o=r(u);o=Object.assign({},o,{per_page:f}),p.customGET("pager",o).then(function(t){function o(){var o=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,o){return o===n.length-1?(t?t[a]=i(e,n):"",t):t?t[a]=t[a]?t[a]:{}:""},t)}}),t}),r=[];n(m,r,""),o.map(function(e){var t=r;t.forEach(function(t){var a=l(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]]})}),s.close();var d=XLSX.utils.json_to_sheet(o),c=XLSX.utils.book_new();XLSX.utils.book_append_sheet(c,d,"dadosexportados");var u=moment().unix();XLSX.writeFile(c,"Exportacao_"+u+".xlsx"),e.export_btn_is_disable=!1}e.$emit("before export",t,o),e.$$listeners["before export"]||o()})}else void 0==e.totalPager||t.dismiss||s.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})}}])}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDFormModalController",["$controller","$scope","$modalInstance","ngToast","headers","Restangular","$stateParams","$timeout","$state","$rootScope","$q","$http","Upload","$modal","data","fwStringService","auth","fwObjectService","fwErrorService",function(t,a,i,n,o,l,r,s,d,c,u,f,p,m,g,b,h,v,y){t("CRUDEditController",{$scope:a,Restangular:l,$stateParams:r,$timeout:s,$modal:m,module:e,$state:d,$rootScope:c,$q:u,ngToast:n,$http:f,Upload:p}),a.data=g||{},a.headers=o,a.resource=l.all(o.route);for(var w in a.headers.fields){var $=a.headers.fields[w];"boolean"==$.type&&void 0==a.data[$.name]&&($.customOptions["default"]?a.data[$.name]=!0:a.data[$.name]=!1)}o.modal_id&&c.$emit("open:"+o.modal_id,a),a.cancel=function(){i.dismiss("cancel")},a.submit=function(){ +this.crudForm.$valid?i.close(a.data):y.emitFormErrors(this.crudForm)},c.$on("cancel-modal",function(e,t){i.dismiss("cancel")}),s(function(){a.$broadcast("setProgressFile")})}])}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDEditController",["$scope","Restangular","$stateParams","$timeout","$modal","module","$state","$rootScope","$q","ngToast","$http","Upload","fwModalService","$window",function(e,t,a,i,n,o,l,r,s,d,c,u,f,p){e.data={},e.dataLoaded=!1,e.module=o,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(){if(a.id)e.$parent.resource.customGET("crudGET/"+a.id).then(function(t){for(var a in e.headers.fields){var n=e.headers.fields[a];if("date"==n.type&&void 0!=t[n.name]&&null!=t[n.name]){var o=new Date(t[n.name]);o.setHours(o.getHours()+o.getTimezoneOffset()/60),t[n.name]=o}n.customOptions&&void 0!=n.customOptions.list&&n.customOptions.list.forEach(function(e){e.id==t[n.name]&&(t[n.name+".label"]=e.label)}),"password"==n.type&&(n.notnull=!1),n.customOptions&&void 0!=n.customOptions.file&&(e.fileName=t[n.name])}e.data=t,e.dataLoaded=!0,i(function(){e.$broadcast("setProgressFile")}),e.$emit("data-loaded")});else{i(function(){e.$emit("data-new")},50);for(var t in e.headers.fields){var n=e.headers.fields[t];"boolean"==n.type&&(e.data[n.name]=n.customOptions["default"]?n.customOptions["default"]:!1)}e.dataLoaded=!0,e.$emit("data-loaded")}},e.headersReady&&e.fetchData(),e.$on("headers-set",function(){e.fetchData()}),e._upload=function(e,t){var a=r.appSettings.API_URL;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/"+e.customOptions.file.container+"/upload":void 0!=e.customOptions.file.url&&void 0!=e.customOptions.file.container&&(a+="upload/"+e.customOptions.file.container+"/"+e.customOptions.file.url),u.upload({url:a,data:{file:t}})},e.download=function(t,a){if(void 0!=t.customOptions.file.container)var i=r.appSettings.API_URL+"upload/"+t.customOptions.file.container+"/download/"+e.data[t.name];else var i=r.appSettings.API_URL+e.module+"/download/"+t.name+"/"+a;e._download(i,t,e.data)},e.downloadDetail=function(t,a,i,n){if(void 0!=a.customOptions.file.container)var o=r.appSettings.API_URL+"upload/"+a.customOptions.file.container+"/download/"+n[a.name];else var o=r.appSettings.API_URL+e.module+"/details/"+t+"/download/"+a.name+"/"+i;e._download(o,a,n)},e._download=function(t,a,i){this.$http({method:"GET",url:t,responseType:"arraybuffer"}).success(function(t,n,o){if(o=o(),void 0!=a.customOptions.file.container)var l=i[a.name];else var l=o["content-disposition"].split(";")[1].split("=")[1].split('"')[1];var r=o["content-type"],s=new Blob([t],{type:r});e.downloadFile(s,l)})},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(o){}},e.getFilter=function(){return decodeURIComponent(p.location.search).replace("?filter=","")},e.submit=function(){function t(t){if(t)i.loading_http_request=!1,t.message?d.warning(t.message):d.warning("Confira seu formulário");else{i.headers.tabs&&Object.keys(i.headers.tabs).forEach(function(e){i.data[e]&&delete i.data[e]});var n;if(a.id){n=e.data.put();var o="edit"}else{n=e.$parent.resource.post(e.data);var o="new"}n.then(function(t){function a(){i.loading_http_request=!1,l.go(l.current.name.replace(".edit",".list").replace(".new",".list"),{filter:e.getFilter()})}e.$emit("after save",a,t,o),e.$$listeners["after save"]||a()},function(t){function a(e){for(var t in i.headers.fields){var a=i.headers.fields[t];if(a.name==e)return a.label}}var n=[];if(i.loading_http_request=!1,422==t.status)if("CANT_SAVE_MODEL"==t.data.error.code)n.push(t.data.error.message);else if(t.data.error.details){var o=t.data.error.details.codes,l={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(o,function(e,t){var i=a(t);"string"==typeof e&&(e=[e]),_.each(e,function(e,t){var a=l[e].replace("%s",i);n.push(a)})})}else n.push(t.data.error.message);d.warning(n.join("
")),e.$emit("error save",t)})}}var i=this,n={},o=i.data;if(_.each(i.headers.fields,function(e,t){o[e.name]||0==o[e.name]||e.notnull||"number"!==e.type||(o[e.name]=null),"password"==e.type&&0!=e.name.indexOf("confirm")&&o["confirm_"+e.name]!=o[e.name]&&(n.password='Os campos "'+e.label+'" e "Confirmar '+e.label+'" não são iguais')}),_.each(i.data,function(e,t){-1!==t.indexOf(".label")&&void 0===o.id&&"object"!=typeof e&&""!==e&&(n[t]="Adicione o(a) "+t.split(".")[0]+" no sistema antes de escolher nesse formulário!"),"data_nascimento"===t&&(moment(e).isAfter(moment())||moment(e).isSame(moment(),"day"))&&(n[t]="Insira uma data de nascimento válida, anterior ao dia de hoje!")}),Object.keys(n).length>0){var r=new Array;_.each(n,function(e,t){r.push(e)}),d.warning(r.join("
"))}else if(this.crudForm.$valid)i.loading_http_request=!0,e.$emit("before save",t),e.$$listeners["before save"]||t();else{var s=[],c=Object.keys(this.crudForm.$error),u=/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/;for(var f in c){var p=this.crudForm.$error[c[f]];for(var m in p){var g=p[m].$options.fieldInfo.label;"required"==c[f]?s.push("O campo "+g+" é obrigatório"):"date"==c[f]&&0==u.test(p[m].$viewValue)&&s.push("O campo "+g+" está com uma data inválida")}}if(s.length>0)d.warning(s.join("
"));else{if(a.id)var b=e.data.put(),h="edit";else var b=e.$parent.resource.post(e.data),h="new";b.then(function(){void 0!=e.doAfterSave&&"function"==typeof e.doAfterSave?e.doAfterSave(resp,h):l.go(l.current.name.replace(".edit",".list").replace(".new",".list"),{filter:e.getFilter()})},function(e){function t(e){for(var t in i.headers.fields){var a=i.headers.fields[t];if(a.name==e)return a.label}}var a=[];if(422==e.status)if("CANT_SAVE_MODEL"==e.data.error.code)a.push(e.data.error.message);else if(e.data.error.details){var n=e.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"};_.each(n,function(e,i){var n=t(i),l=o[e].replace("%s",n);a.push(l)})}else a.push(e.data.error.message);d.warning(a.join("
"))})}}},e.cancel=function(){l.go(l.current.name.replace(".edit",".list").replace(".new",".list"),{filter:e.getFilter()})},e.autocompleteModels={},e.autocompleteAdd=function(e){},e._autocomplete=function(t,a,i){var n=[],o=s.defer();if(t.autocomplete_dependencies.length>0){var l=t.autocomplete_dependencies;for(var r in l){var d=l[r];if(void 0==e.data[d.field]||null==e.data[d.field]){var c="Selecione antes o(a) "+d.label,u=[];return u.push({id:null,label:c}),o.resolve(u),o.promise}n[d.field]=e.data[d.field]}}if(a=a.trim(),(0==a.length||1==t.customOptions.select)&&(a="[blank]"),void 0!==t.customOptions.general)e.resource.customGET("general/autocomplete/"+t.customOptions.general+"/"+a,n).then(function(e){t.quickAdd===!0&&"[blank]"!=a&&e.push({id:-1,label:"Adicionar novo: "+a}),o.resolve(e)},function(){return o.reject()});else if(void 0==t.customOptions.list){if(i)var f="details/"+i+"/autocomplete/"+t.name+"/"+a;else var f="autocomplete/"+t.name+"/"+a;1==t.customOptions.select?n.limit=0:n.limit=20,e.resource.customGET(f,n).then(function(e){1==t.customOptions.select&&e.unshift({id:null,label:"--- Selecione ---"}),t.quickAdd===!0&&"[blank]"!=a&&e.push({id:-1,label:"Adicionar novo: "+a}),o.resolve(e)},function(){return o.reject()})}else{var p=angular.copy(t.customOptions.list)||[];1==t.customOptions.select&&p.unshift({id:null,label:"--- Selecione ---"}),o.resolve(p)}return o.promise},e.autocomplete=function(e,t){return this._autocomplete(e,t,null)},e.autocompleteDetail=function(e,t,a){return this._autocomplete(t,a,e)},e.doafterAutoCompleteSelect={},e._autocompleteSelect=function(t,a,n,o){var l=o?this.detail_data:this.data;if(void 0==l&&(l={}),null!=t.id&&"integer"!=typeof t.id||"integer"==typeof t.id&&t.id>0)l[this.field.name]=t.id;else{if(null!=t.id)return l[this.field.name+".label"]=null,!1;l[this.field.name]=l[this.field.name+".label"]=null}"function"==typeof e.doafterAutoCompleteSelect[this.field.name]&&e.doafterAutoCompleteSelect[this.field.name].call(this,l,t,a,n),o?this.detail_data=l:this.data=l;var r=this.field;i(function(){jQuery("#"+r.name).trigger("keyup")})},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)},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);e.headers.parent_route?e.headers.parent_route:e.headers.route.toLowerCase();t.route=i?n:e.headers.route+t.fixedRoute,t.id=i?i:null,f.createCRUDModal(t,null,"CRUDEditDetailController")},e.deleteDetail=function(e,a){var i=t.all(e);i.customDELETE(a.id).then(function(){r.$broadcast("refreshGRID"),r.$broadcast("data-grid-updated",{type:e.split("/").pop()})},function(e){d.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,f.createCRUDModal(n).then(function(t){t["new"]=!0,e.data[a].push(t)})}else{var o={},l=e.headers[t][a].fields;for(var r in l)"boolean"!=l[r].type?o[l[r].name]=null:o[l[r].name]=!1;o["new"]=!0,e.data[a].push(o),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,f.createCRUDModal(n,i).then(function(t){e.data[a][e.data[a].indexOf(i)]=t})},e.deleteDetailData=function(e,t){window.confirm("Deseja realmente excluir esse item?")&&this.data[t].splice(this.data[t].indexOf(e),1)}}])}(),function(){"use strict";var e=angular.module("letsAngular");e.controller("CRUDEditDetailController",["$scope","Restangular","$http","$stateParams","$timeout","headers","$rootScope","$modalInstance","$q","ngToast","Upload",function(e,t,a,i,n,o,l,r,s,d,c){e.data={},e.headers=o,e.resource=t.all(o.route),e.autocompleteModels={},e.doafterAutoCompleteSelect={},e.$http=a,o.modal_id&&l.$emit("open:"+o.modal_id,e),e.datepickers={},e.datepickerToggle=function(t){void 0==e.datepickers[t]&&(e.datepickers[t]=!1),e.datepickers[t]=!e.datepickers[t]};for(var u in e.headers.fields){var f=e.headers.fields[u];"boolean"==f.type&&(e.data[f.name]=!1)}if(o.id)e.resource.customGET(o.id).then(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 o=new Date(t[i.name]);o.setHours(o.getHours()+o.getTimezoneOffset()/60),t[i.name]=o}i.customOptions&&void 0!=i.customOptions.list&&i.customOptions.list.forEach(function(e){e.id==t[i.name]&&(t[i.name+".label"]=e.label)}),"password"==i.type&&(i.notnull=!1)}e.data=t,n(function(){e.$broadcast("setProgressFile")}),e.$emit("data-loaded-detail")});else{n(function(){e.$emit("data-new-detail")},50);for(var u in e.headers.fields){var f=e.headers.fields[u];"boolean"==f.type&&(e.data[f.name]=f.customOptions["default"]?f.customOptions["default"]:!1)}}n(function(){e.submit=function(){function t(){if(e.data.id)var t=e.resource.customPUT(e.data,e.data.id),n="edit";else var t=e.resource.customPOST(e.data,i.id),n="new";t.then(function(t){function a(){l.$broadcast("refreshGRID"),r.dismiss("success")}e.$emit("after save",a,t,n),e.$$listeners["after save"]||a()},function(t){function i(e){for(var t in a.headers.fields){var i=a.headers.fields[t];if(i.name==e)return i.label}}var n=[];if(422==t.status)if("CANT_SAVE_MODEL"==t.data.error.code)n.push(t.data.error.message);else if(t.data.error.details){var o=t.data.error.details.codes,l={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(o,function(e,t){var a=i(t);"string"==typeof e&&(e=[e]),_.each(e,function(e,t){var i=l[e].replace("%s",a);n.push(i)})})}else n.push(t.data.error.message);d.warning(n.join("
")),e.$emit("error save",t)})}var a=this,n={},o=a.data;if(_.each(a.headers.fields,function(e,t){"password"==e.type&&0!=e.name.indexOf("confirm")&&o["confirm_"+e.name]!=o[e.name]&&(n.password='Os campos "'+e.label+'" e "Confirmar '+e.label+'" não são iguais')}),Object.keys(n).length>0){var s=new Array;_.each(n,function(e,t){s.push(e)}),d.warning(s.join("
"))}else this.crudForm.$valid&&(e.$emit("before save",t),e.$$listeners["before save"]||t())},e.cancel=function(){r.dismiss("success")},e._upload=function(e,t){var a=l.appSettings.API_URL;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/"+e.customOptions.file.container+"/upload":void 0!=e.customOptions.file.url&&void 0!=e.customOptions.file.container&&(a+="upload/"+e.customOptions.file.container+"/"+e.customOptions.file.url),c.upload({url:a,data:{file:t}})},e.download=function(t,a){if(void 0!=t.customOptions.file.container)var i=l.appSettings.API_URL+"upload/"+t.customOptions.file.container+"/download/"+e.data[t.name];else var i=l.appSettings.API_URL+e.module+"/download/"+t.name+"/"+a;e._download(i,t,e.data)},e.downloadDetail=function(t,a,i,n){if(void 0!=a.customOptions.file.container)var o=l.appSettings.API_URL+"upload/"+a.customOptions.file.container+"/download/"+n[a.name];else var o=l.appSettings.API_URL+e.module+"/details/"+t+"/download/"+a.name+"/"+i;e._download(o,a,n)},e._download=function(t,a,i){this.$http({method:"GET",url:t,responseType:"arraybuffer"}).success(function(t,n,o){if(o=o(),void 0!=a.customOptions.file.container)var l=i[a.name];else var l=o["content-disposition"].split(";")[1].split("=")[1].split('"')[1];var r=o["content-type"],s=new Blob([t],{type:r});e.downloadFile(s,l)})},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(o){}},e._autocomplete=function(t,a,i){var n=[],o=s.defer();if(t.autocomplete_dependencies.length>0){var l=t.autocomplete_dependencies;for(var r in l){var d=l[r];if(void 0==e.data[d.field]||null==e.data[d.field]){var c="Selecione o "+d.label,u=[];return u.push({id:null,label:c}),o.resolve(u),o.promise}e.data[d.field].id?n[d.field]=e.data[d.field].id:n[d.field]=e.data[d.field]}}if(a=a.trim(),(0==a.length||1==t.customOptions.select)&&(a="[blank]"),void 0==t.customOptions.list){var f="autocomplete/"+t.name+"/"+a;1==t.customOptions.select?n.limit=0:n.limit=20,e.resource.customGET(f,n).then(function(e){1==t.customOptions.select&&e.unshift({id:null,label:"--- Selecione ---"}),t.quickAdd===!0&&"[blank]"!=a&&e.push({id:null,label:"Adicionar novo: "+a}),o.resolve(e)},function(){return o.reject()})}else{var p=angular.copy(t.customOptions.list)||[];1==t.customOptions.select&&p.unshift({id:null,label:"--- Selecione ---"}),o.resolve(p)}return o.promise},e._autocompleteSelect=function(t,a,i,o){if(null!=t.id&&"integer"!=typeof t.id||"integer"==typeof t.id&&t.id>0)this.data[this.field.name]=t.id;else{if(null!=t.id)return this.data[this.field.name+".label"]=null,!1;this.data[this.field.name]=this.data[this.field.name+".label"]=null}"function"==typeof e.doafterAutoCompleteSelect[this.field.name]&&e.doafterAutoCompleteSelect[this.field.name].call(this,this.data,t,a,i);var l=this.field;n(function(){jQuery("#"+l.name).trigger("keyup")})},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)}},500)}])}(),angular.module("letsAngular").run(["$templateCache",function(e){e.put("lets/views/crud/crud-detail-list.html",'
{{field.label}}{{field.label}}Ações
Nenhum dado cadastrado.
'),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",'
Informações Principais
Informações Principais
'),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$
  • A data informada é inválida.
  • O horário informado é inválido.
{{ f.progress + \'%\' }} {{ f.name }} {{ f.newName }}
{{ column.label }}
{{ data[column.name] }}
'); }]); \ No newline at end of file diff --git a/package.json b/package.json index 7ef33ef..3d29e14 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "test": "gulp test" }, "devDependencies": { + "del": "~2.0.2", "gulp": "^3.9.1", "gulp-angular-filesort": "~1.1.1", "gulp-angular-templatecache": "~1.8.0", @@ -27,16 +28,50 @@ "gulp-replace": "~0.5.4", "gulp-rev": "~6.0.1", "gulp-rev-replace": "~0.4.2", - "gulp-sass": "~2.0.4", + "gulp-sass": "^3.0.0", "gulp-size": "~2.0.0", "gulp-sourcemaps": "~1.6.0", "gulp-uglify": "~1.4.1", "gulp-useref": "~1.3.0", "gulp-util": "^3.0.8", - "wrench": "~1.5.8", - "del": "~2.0.2" + "wrench": "~1.5.8" }, "engines": { "node": ">=0.10.0" + }, + "eslintConfig": { + "extends": [ + "plugin:angular/johnpapa" + ], + "plugins": [ + "angular" + ], + "rules": { + "angular/no-service-method": 0, + "angular/file-name": 0, + "angular/controller-as-vm": 0, + "angular/document-service": 0, + "angular/controller-name": 0, + "angular/controller-as": 0, + "angular/timeout-service": 0, + "angular/window-service": 0 + }, + "env": { + "es6": true, + "browser": true, + "jasmine": true + }, + "ecmaFeatures": { + "modules": true + }, + "globals": { + "angular": true, + "module": true, + "inject": true, + "jQuery": true, + "$": true, + "swal": true, + "ngDescribe": true + } } } diff --git a/src/directives/crud/lets-crud-filter.directive.js b/src/directives/crud/lets-crud-filter.directive.js index a7d3700..4254cdf 100644 --- a/src/directives/crud/lets-crud-filter.directive.js +++ b/src/directives/crud/lets-crud-filter.directive.js @@ -1,328 +1,341 @@ (function () { - 'use strict'; - - angular.module('letsAngular').directive('crudFilter', crudFilter); - - crudFilter.$inject = ['$q','Restangular', '$timeout', '$rootScope']; - - function crudFilter($q, Restangular, $timeout, $rootScope) { - return { - templateUrl: 'lets/views/crud/crud-filter.html', - replace: true, - scope: { - fields: '&', - route: '&', - search:'&', - clearButton: '=clearButton' - }, - controller: function ($scope) { - - }, - link: function (scope, $el) { - - scope.data = {}; - scope.showBuscaAvancada = false; - var fields; - - scope.fieldsFilter = []; - - - - scope.startFilters = function() { - fields = angular.copy(scope.fields()); - scope.fieldsFilter = []; - fields = fields.filter(function(field){return field.filter}); - fields.forEach(function(field, idx){ - if (!field.filter)return; - - field.disabled = false; - field.notnull = false; - field.name = field.name; - - if (field.customOptions.file){ - delete field.customOptions.file; - } - if(field.customOptions.multiselect){ - field.type = "multiselect" - field.autocomplete = false - } - if (field.type=="text"){ - field.type = "string"; - } - else if (field.type=="boolean"){ - field.type = "number"; - field.autocomplete = true; - field.customOptions = { - "list":[ - {"id":"false", "label":field.customOptions.statusFalseText}, - {"id":"true", "label":field.customOptions.statusTrueText} - ], - "select":true - }; - } - else if (field.type=="date"){ - - if (typeof(field.filter)=="object" && field.filter.range===true){ - - var _ini = angular.copy(field); - _ini.name +="_ini"; - _ini.label +=" (Início)"; - scope.fieldsFilter.push(_ini); - - var _fim = angular.copy(field); - _fim.name +="_fim"; - // Não mudar para "fim", ordenação está por ordem alfabética do label ! - _fim.label +=" (Término)"; - scope.fieldsFilter.push(_fim); - - return; - } - - } - else if (field.type == "number" || field.type == "integer" || field.type == "float" || field.type == "bigint"){ - - if (typeof(field.filter)=="object" && field.filter.range===true){ - - var _ini = angular.copy(field); - _ini.name +="_ini"; - _ini.label +=" (Início)"; - scope.fieldsFilter.push(_ini); - - var _fim = angular.copy(field); - _fim.name +="_fim"; - // Não mudar para "fim", ordenação está por ordem alfabética do label ! - _fim.label +=" (Término)"; - scope.fieldsFilter.push(_fim); - - return; - } - - } - - scope.fieldsFilter.push(field); - }); - - scope.fieldsFilter = scope.fieldsFilter.sort(function(a, b) { - var filter1 = a.filter.sequence || 0; - var filter2 = b.filter.sequence || 0; - return filter1 - filter2; - }); - - - setTimeout(function(){ - scope.$emit('filter-init', scope); - scope.$broadcast('filter-init', scope); - }, 500); - } - - - scope.autocomplete = function (field, val) { - scope.$emit('before-filter-autocomplete', scope); - - scope.resource = Restangular.all(scope.route()); - - var queries = []; - - var deferred = $q.defer(); - - if (field.autocomplete_dependencies.length > 0) { - var deps = field.autocomplete_dependencies; - for (var x in deps) { - var dep = deps[x]; - if (scope.data[dep.field] == undefined || scope.data[dep.field] == null || scope.data[dep.field] == "null") { - - var text = 'Selecione antes o(a) ' + dep.label; - - var data = []; - data.push({ id: null, label: text }); - - deferred.resolve(data); - - return deferred.promise; - } else { - queries[dep.field] = scope.data[dep.field]; - } - } - } - - val = val.trim(); - if (val.length == 0 || field.customOptions.select == true) { - val = '[blank]'; - } - - if (field.customOptions.general !== undefined) { - - scope.resource.customGET('general/autocomplete/' + field.customOptions.general + '/' + val, queries).then(function (data) { - deferred.resolve(data); - }, function errorCallback() { - return deferred.reject(); - }); - - } else if (field.customOptions.list == undefined) { - - var route = 'autocomplete/' + field.name+ '/' + val; - - if (field.customOptions.select == true){ - queries["limit"] = 0; - }else{ - queries["limit"] = 20; - } - - scope.resource.customGET(route, queries).then(function (data) { - // if (field.customOptions.select == true) { - data.unshift({ id: "null", label: '[Em Branco]' }); - data.unshift({ id: null, label: '--- Selecione ---' }); - // } - deferred.resolve(data); - }, function errorCallback() { - return deferred.reject(); - }); - - } else { - - var options = angular.copy(field.customOptions.list) || []; - - if (field.customOptions.select == true) { - if (!field.customOptions.onlyList){ - options.unshift({ id: "null", label: '[Em Branco]' }); - } - if (!field.customOptions.required){ - options.unshift({ id: null, label: '--- Selecione ---' }); - } - } - - deferred.resolve(options); - } - return deferred.promise; - } - - scope.autocompleteSelect = function ($item, $model, $label) { - // debugger; - - scope.$emit('after-filter-autocomplete', {scope: scope, name: this.field.name, value: $item}); - - var _data = this.data; - - if (_data==undefined){ - _data = {}; - } - - if ($item.id != null && typeof $item.id != 'integer' || (typeof $item.id == 'integer' && $item.id > 0)) { - _data[this.field.name] = $item.id; - } - else if ($item.id == null) { - _data[this.field.name] = _data[this.field.name + '.label'] = null; - } - else { - _data[this.field.name + '.label'] = null; - return false; - } - - this.data = _data; - - var field = this.field; - $timeout(function(){ - jQuery('#'+field.name).trigger('keyup'); - }); - } - - scope.filterData = function(start){ - scope.objFilter = undefined; - - var filterData = {}; - if(scope.data['showBuscaAvancada']){ - scope.showBuscaAvancada = angular.copy(scope.data['showBuscaAvancada']); - delete scope.data['showBuscaAvancada']; - } - - if ( scope.showBuscaAvancada || scope.data['showBusca'] ) { - fields.forEach(function(field, idx){ - - if (typeof(field.filter)=="object" && field.filter.range===true){ - - var values = {}; - - if (scope.data[field.name+"_ini"]){ - values.ini = scope.data[field.name+"_ini"]; - if (field.type=="date"){ - values.ini = scope.getDateFormated(values.ini); - } - } - - if (scope.data[field.name+"_fim"]){ - values.fim = scope.data[field.name+"_fim"]; - if (field.type=="date"){ - values.fim = scope.getDateFormated(values.fim); - } - } - - if (Object.keys(values).length>0){ - filterData[field.name] = values; - } - - } - - if (scope.data[field.name]){ - - filterData[field.name] = scope.data[field.name]; - - if(field.customOptions && field.customOptions.telefone){ - filterData[field.name] = scope.data[field.name].replace(/\D/g, '') - } - if(field.type=="date"){ - filterData[field.name] = scope.getDateFormated(filterData[field.name]) - } - - if(field.autocomplete && !field.customOptions.multiselect){ - filterData[field.name+"_label"] = scope.data[field.name+".label"].label; - } - - if (field.autocomplete && field.customOptions.multiselect){ - filterData[field.name] = scope.data[field.name]; - } - } - }); - scope.data.q = null; - - scope.objFilter = {data:{filter:filterData}}; - }else{ - filterData.q = scope.data.q; - filterData.p = scope.data.p; - scope.objFilter = {data:filterData}; - } - - if(start){ - $rootScope.$broadcast('refreshGRID', false, true); - } - } - - scope.openBuscaAvancada = function(){ - scope.showBuscaAvancada = !scope.showBuscaAvancada; - // scope.filterData(true); - } - scope.clearBusca = function(){ - Object.keys(scope.data).forEach(function (prop){ - scope.data[prop] = null - }); - scope.filterData(true); - } - - scope.getDateFormated = function(dt){ - return moment(dt).format('DD/MM/YYYY'); - } - - scope.startFilters(); - - scope.$on('refresh-fields', function(e, data) { - scope.startFilters(); - }); - - if(scope.search()=="fixed"){ - scope.showBuscaAvancada = true; - scope.hideInputSearch = true; - } - - } - } - } -})(); \ No newline at end of file + 'use strict'; + + angular.module('letsAngular').directive('crudFilter', crudFilter); + + crudFilter.$inject = ['$q', 'Restangular', '$timeout', '$rootScope']; + + function crudFilter($q, Restangular, $timeout, $rootScope) { + return { + templateUrl: 'lets/views/crud/crud-filter.html', + replace: true, + scope: { + fields: '&', + route: '&', + search: '&', + clearButton: '=clearButton', + }, + controller: function ($scope) {}, + link: function (scope, $el) { + scope.data = {}; + scope.showBuscaAvancada = false; + var fields; + + scope.fieldsFilter = []; + + scope.startFilters = function () { + fields = angular.copy(scope.fields()); + scope.fieldsFilter = []; + fields = fields.filter(function (field) { + return field.filter; + }); + fields.forEach(function (field, idx) { + if (!field.filter) return; + field.disabled = false; + field.notnull = false; + field.name = field.name; + + if (field.customOptions != undefined && field.customOptions.file) { + delete field.customOptions.file; + } + if (field.customOptions.multiselect) { + field.type = 'multiselect'; + field.autocomplete = false; + } + if (field.type == 'text') { + field.type = 'string'; + } else if (field.type == 'boolean') { + field.type = 'number'; + field.autocomplete = true; + field.customOptions = { + 'list': [ + {'id': 'false', 'label': field.customOptions.statusFalseText}, + {'id': 'true', 'label': field.customOptions.statusTrueText}, + ], + 'select': true, + }; + } else if (field.type == 'olddate') { + if (typeof field.filter == 'object' && field.filter.range === true) { + // console.log({field: field, scope: scope}); + var _ini = angular.copy(field); + _ini.name += '_ini'; + _ini.label += ' (Início)'; + scope.fieldsFilter.push(_ini); + + var _fim = angular.copy(field); + _fim.name += '_fim'; + // Não mudar para "fim", ordenação está por ordem alfabética do label ! + _fim.label += ' (Término)'; + scope.fieldsFilter.push(_fim); + + return; + } + } else if (field.type == 'date') { + field.filter['_edit'] = true; + if (typeof field.filter == 'object' && field.filter.range === true) { + // console.log({field: field, scope: scope}); + + // var _ini = angular.copy(field); + // _ini.name +="_ini"; + // _ini.label +=" (Início)"; + scope.fieldsFilter.push(field); + // // var _fim = angular.copy(); + // var _fim = angular.copy(field); + // _fim.name +="_fim"; + // // Não mudar para "fim", ordenação está por ordem alfabética do label ! + // _fim.label +=" (Término)"; + // scope.fieldsFilter.push(_fim); + + return; + } + } else if (field.type == 'number' || field.type == 'integer' || field.type == 'float' || field.type == 'bigint') { + if (typeof field.filter == 'object' && field.filter.range === true) { + var _ini = angular.copy(field); + _ini.name += '_ini'; + _ini.label += ' (Início)'; + scope.fieldsFilter.push(_ini); + + var _fim = angular.copy(field); + _fim.name += '_fim'; + // Não mudar para "fim", ordenação está por ordem alfabética do label ! + _fim.label += ' (Término)'; + scope.fieldsFilter.push(_fim); + + return; + } + } + + scope.fieldsFilter.push(field); + }); + + scope.fieldsFilter = scope.fieldsFilter.sort(function (a, b) { + var filter1 = a.filter.sequence || 0; + var filter2 = b.filter.sequence || 0; + return filter1 - filter2; + }); + + setTimeout(function () { + scope.$emit('filter-init', scope); + scope.$broadcast('filter-init', scope); + }, 500); + }; + + scope.autocomplete = function (field, val) { + scope.$emit('before-filter-autocomplete', scope); + + scope.resource = Restangular.all(scope.route()); + + var queries = []; + + var deferred = $q.defer(); + + if (field.autocomplete_dependencies.length > 0) { + var deps = field.autocomplete_dependencies; + for (var x in deps) { + var dep = deps[x]; + if (scope.data[dep.field] == undefined || scope.data[dep.field] == null || scope.data[dep.field] == 'null') { + var text = 'Selecione antes o(a) ' + dep.label; + + var data = []; + data.push({id: null, label: text}); + + deferred.resolve(data); + + return deferred.promise; + } else { + queries[dep.field] = scope.data[dep.field]; + } + } + } + + val = val.trim(); + if (val.length == 0 || field.customOptions.select == true) { + val = '[blank]'; + } + + if (field.customOptions.general !== undefined) { + scope.resource.customGET('general/autocomplete/' + field.customOptions.general + '/' + val, queries).then( + function (data) { + deferred.resolve(data); + }, + function errorCallback() { + return deferred.reject(); + } + ); + } else if (field.customOptions.list == undefined) { + var route = 'autocomplete/' + field.name + '/' + val; + + if (field.customOptions.select == true) { + queries['limit'] = 0; + } else { + queries['limit'] = 20; + } + + scope.resource.customGET(route, queries).then( + function (data) { + // if (field.customOptions.select == true) { + data.unshift({id: 'null', label: '[Em Branco]'}); + data.unshift({id: null, label: '--- Selecione ---'}); + // } + deferred.resolve(data); + }, + function errorCallback() { + return deferred.reject(); + } + ); + } else { + var options = angular.copy(field.customOptions.list) || []; + + if (field.customOptions.select == true) { + if (!field.customOptions.onlyList) { + options.unshift({id: 'null', label: '[Em Branco]'}); + } + if (!field.customOptions.required) { + options.unshift({id: null, label: '--- Selecione ---'}); + } + } + + deferred.resolve(options); + } + return deferred.promise; + }; + + scope.autocompleteSelect = function ($item, $model, $label) { + // debugger; + + scope.$emit('after-filter-autocomplete', {scope: scope, name: this.field.name, value: $item}); + + var _data = this.data; + + if (_data == undefined) { + _data = {}; + } + + if (($item.id != null && typeof $item.id != 'integer') || (typeof $item.id == 'integer' && $item.id > 0)) { + _data[this.field.name] = $item.id; + } else if ($item.id == null) { + _data[this.field.name] = _data[this.field.name + '.label'] = null; + } else { + _data[this.field.name + '.label'] = null; + return false; + } + + this.data = _data; + + var field = this.field; + $timeout(function () { + jQuery('#' + field.name).trigger('keyup'); + }); + }; + + scope.filterData = function (start) { + scope.objFilter = undefined; + + var filterData = {}; + if (scope.data['showBuscaAvancada']) { + scope.showBuscaAvancada = angular.copy(scope.data['showBuscaAvancada']); + delete scope.data['showBuscaAvancada']; + } + + if (scope.showBuscaAvancada || scope.data['showBusca']) { + fields.forEach(function (field, idx) { + if (typeof field.filter == 'object' && field.filter.range === true) { + var values = {}; + + if (scope.data[field.name]) { + if (field.type == 'date') { + values.ini = scope.data[field.name].startDate; + values.fim = scope.data[field.name].endDate; + // console.log('showBuscaValue', values); + // console.log('showBuscascope', scope); + + values.ini = scope.getDateFormated(values.ini); + values.fim = scope.getDateFormated(values.fim); + if (Object.keys(values).length > 0) { + // filterData[field.name + '_ini'] = values.ini; + // filterData[field.name + '_fim'] = values.fim; + delete filterData[field.name]; + filterData[field.name] = values; + + // console.log({values: values}, filterData); + // filterData[field.name] = values; + } + } else if (field.type == 'olddate') { + if (scope.data[field.name + '_ini']) { + values.ini = scope.data[field.name + '_ini']; + if (field.type == 'date') { + values.ini = scope.getDateFormated(values.ini); + } + } + + if (scope.data[field.name + '_fim']) { + values.fim = scope.data[field.name + '_fim']; + if (field.type == 'date') { + values.fim = scope.getDateFormated(values.fim); + } + } + + if (Object.keys(values).length > 0) { + filterData[field.name] = values; + } + } + } + } else if (scope.data[field.name]) { + filterData[field.name] = scope.data[field.name]; + if (field.customOptions && field.customOptions.telefone) { + filterData[field.name] = scope.data[field.name].replace(/\D/g, ''); + } else if (field.type == 'olddate') { + filterData[field.name] = scope.getDateFormated(filterData[field.name]); + } else if (field.type == 'date' && field.filter && field.filter.range != true) { + // console.log({field: field}); + filterData[field.name] = scope.getDateFormated(filterData[field.name]); + } else if (field.autocomplete && !field.customOptions.multiselect) { + filterData[field.name + '_label'] = scope.data[field.name + '.label'].label; + } else if (field.autocomplete && field.customOptions.multiselect) { + filterData[field.name] = scope.data[field.name]; + } + } + }); + scope.data.q = null; + + scope.objFilter = {data: {filter: filterData}}; + } else { + filterData.q = scope.data.q; + filterData.p = scope.data.p; + scope.objFilter = {data: filterData}; + } + + if (start) { + $rootScope.$broadcast('refreshGRID', false, true); + } + }; + + scope.openBuscaAvancada = function () { + scope.showBuscaAvancada = !scope.showBuscaAvancada; + // scope.filterData(true); + }; + scope.clearBusca = function () { + Object.keys(scope.data).forEach(function (prop) { + scope.data[prop] = null; + }); + scope.filterData(true); + }; + + scope.getDateFormated = function (dt) { + return moment(dt).format('DD/MM/YYYY'); + }; + + scope.startFilters(); + + scope.$on('refresh-fields', function (e, data) { + scope.startFilters(); + }); + + if (scope.search() == 'fixed') { + scope.showBuscaAvancada = true; + scope.hideInputSearch = true; + } + }, + }; + } +})(); diff --git a/src/directives/crud/lets-crud-form.directive.js b/src/directives/crud/lets-crud-form.directive.js index 923e8bb..9a96161 100644 --- a/src/directives/crud/lets-crud-form.directive.js +++ b/src/directives/crud/lets-crud-form.directive.js @@ -15,7 +15,7 @@ //Set options for dropzone for (var y in scope.headers.fields) { var field = scope.headers.fields[y]; - if (field.customOptions.file) { + if (field.customOptions && field.customOptions.file) { scope.dzOptions = { url: appSettings.API_URL + 'upload/' + field.customOptions.file.container + '/upload', acceptedFiles: field.customOptions.file.acceptedFiles, diff --git a/src/directives/crud/lets-crud-list.directive.js b/src/directives/crud/lets-crud-list.directive.js index 8632214..68e0157 100644 --- a/src/directives/crud/lets-crud-list.directive.js +++ b/src/directives/crud/lets-crud-list.directive.js @@ -1,685 +1,649 @@ (function () { - 'use strict'; - - angular.module('letsAngular') - .directive('crudList', crudList); - - crudList.$inject = ['$window', 'jQuery', 'Backbone', 'Backgrid', 'appSettings', 'fwObjectService', '$timeout', '$state']; - - function crudList($window, jQuery, Backbone, Backgrid, appSettings, fwObjectService, $timeout, $state) { - return { - scope: { - crudListSettings: '&', - crudListDependenciesData: '&', - app: '=', - }, - controller: function ($scope) { - $scope.route = null; - - $scope.$on('refreshGRID', function (event, start, filter) { - $scope.pageableCRUDModel.fetch(null, start, filter); - }); - }, - link: function (scope, $el, attrs) { - - scope.$el = $el; - - function render() { - var settings = scope.crudListSettings(); - settings.route = appSettings.API_URL + settings.url; - scope.route = settings.route; - - Backgrid.InputCellEditor.prototype.attributes.class = 'form-control input-sm'; - - var CRUDModel = Backbone.Model.extend({}); - - var paramsPageable = { - model: CRUDModel, - url: settings.route + (!settings.pagerGeneral ? '/pager' : '/pagerGeneral'), - state: { - pageSize: 20 - }, - mode: 'server', - parseRecords: function (resp, options) { - if( scope.$el[0].parseRecords && typeof(scope.$el[0].parseRecords)=="function" ){ - return scope.$el[0].parseRecords(resp.data); - }else{ - return resp.data; - } - }, - parseState: function (resp, queryParams, state, options) { - - $timeout(function(){ - var infoTotal = jQuery("
    "); - infoTotal.append(jQuery("
  • ").html("Registros na página: "+resp.total_entries+" / "+resp.total_count)); - scope.$el.find('.table-container .backgrid-paginator ul.total-records').remove(); - scope.$el.find('.table-container .backgrid-paginator').append(infoTotal); - }); - // Sempre pegar atualizado (não causa problema em páginas customizadas) - scope.$parent.totalPager = resp.total_count; - return { totalRecords: resp.total_count }; - }, - }; - - if (settings.filterScope){ - paramsPageable.queryParams = { - scope: settings.filterScope - }; - } - - if (settings.sort){ - paramsPageable.state.sortKey = settings.sort.sortKey; - if (settings.sort.order && settings.sort.order=="desc"){ - paramsPageable.state.order = 1; - } - } - - var PageableCRUDModel = Backbone.PageableCollection.extend(paramsPageable); - - var pageableCRUDModel = new PageableCRUDModel(), - initialCRUDModel = pageableCRUDModel; - - scope.pageableCRUDModel = pageableCRUDModel; - - function createBackgrid(collection) { - var columns = []; - - var StringFormatter = function () {}; - StringFormatter.prototype = new Backgrid.StringFormatter(); - - _.extend(StringFormatter.prototype, { - fromRaw: function (rawValue, b, c, d, e) { - return rawValue; - } - }); - - _.each(settings.fields, function (field, idx) { - - if (field.viewable) { - var cellOptions = { - name: field.name, - label: field.label, - cell: 'string', - editable: false, - headers: field - }; - - if (field.type == 'boolean') { - cellOptions.sortable = false; - cellOptions.cell = Backgrid.Cell.extend({ - className: "custom-situation-cell", - formatter: { - fromRaw: function (rawData, model) { - return rawData ? field.customOptions.statusTrueText : field.customOptions.statusFalseText; - }, - toRaw: function (formattedData, model) { - return 'down'; - } - } - - }); - } - else if (field.type == 'simplecolor') { - cellOptions.sortable = false; - cellOptions.cell = Backgrid.Cell.extend({ - className: "custom-situation-cell", - initialize: function () { - Backgrid.Cell.prototype.initialize.apply(this, arguments); - }, - render: function () { - this.$el.empty(); - var formattedValue = ''; - this.$el.append(formattedValue); - this.delegateEvents(); - return this; - } - }); - } - else if (field.type == 'custom') { - var customFormatter = { - fromRaw: field.toString, - toRaw: function (formattedData, model) { - return 'down'; - } - }; - - cellOptions.sortable = false; - var _backgridCellExtend = Backgrid.Cell.extend({ - className: "custom-cell", - formatter: customFormatter - }); - - _backgridCellExtend.initialize = function () { - Backgrid.Cell.prototype.initialize.apply(this, arguments); - }; - _backgridCellExtend.render = function () { - this.$el.empty(); - this.$el.data('model', this.model); - var formattedValue = customFormatter.fromRaw(this.model); - this.$el.append(formattedValue); - this.delegateEvents(); - return this; - }; - - cellOptions.cell = Backgrid.Cell.extend(_backgridCellExtend); - } - else if (field.type == 'address') { - var addressFormatter = { - fromRaw: function (rawData, model) { - try { - return rawData.city + ' - ' + rawData.state; - } catch (err) { - return ''; - } - - }, - toRaw: function (formattedData, model) { - return 'down'; - } - }; - - var AddressCell = Backgrid.Cell.extend({ - className: "address-cell", - formatter: addressFormatter - - }); - - cellOptions.cell = AddressCell; - - } - else if (field.type == 'float') { - - if( field.customOptions && field.customOptions.currency ){ - cellOptions.cell = Backgrid.Cell.extend({ - formatter: { - fromRaw: function (rawData, model) { - if (rawData){ - var rawData = rawData.toFixed(2).split('.'); - rawData[0] = "R$ " + rawData[0].split(/(?=(?:...)*$)/).join('.'); - return rawData.join(','); - } - - } - } - }); - }else{ - cellOptions.cell = Backgrid.NumberCell.extend({ - decimalSeparator: ',', - orderSeparator: '.' - }); - } - - } - else if (field.type == 'date') { - - var format = "DD/MM/YYYY"; - var modelFormat="YYYY/M/D"; - var displayInUTC=true; - - if (field.customOptions.monthpicker !== undefined) { - format = "MM/YYYY"; - } - - if (field.customOptions.timestamp) { - modelFormat="YYYY/M/D HH:mm:ss.SSS"; - displayInUTC=false; - } - - cellOptions.cell = Backgrid.Extension.MomentCell.extend({ - modelFormat: modelFormat, - displayLang: "pt-br", - displayFormat: format, - displayInUTC: displayInUTC - }); - } - else if (field.customOptions.enum != undefined) { - - var enumOptions = []; - for (var _idx in field.customOptions.enum) { - var opt = field.customOptions.enum[_idx]; - enumOptions.push([opt, _idx]); - } - - cellOptions.cell = Backgrid.SelectCell.extend({ - optionValues: enumOptions - }); - - } - else if (field.autocomplete == true) { - - if (field.customOptions && field.customOptions.list!=undefined) { - - cellOptions.cell = Backgrid.Cell.extend({ - className: "custom-situation-cell-select", - formatter: { - fromRaw: function (rawData, model) { - - var label=""; - field.customOptions.list.forEach(function(item){ - if (item.id==rawData){ - label = item.label; - } - }); - - return label; - - }, - toRaw: function (formattedData, model) { - return 'down'; - } - } - - }); - - - }else{ - cellOptions.name = cellOptions.name + '.label'; - } - - } - - columns.push(cellOptions); - } - }); - - var ActionCell = Backgrid.Cell.extend({ - className: 'text-right btn-column' + (settings.tab == true ? ' detail' : ''), - template: function () { - var _buttons = []; - if (!settings.tab) { - if (settings.settings.edit) { - _buttons.push(jQuery('')); - } - if (settings.settings.delete) { - _buttons.push(jQuery('')); - } - } else { - if (settings.settings) { - if (settings.settings.edit) { - var _btnEditDetail = jQuery(''); - _btnEditDetail.attr('data-route', settings.url); - _buttons.push(_btnEditDetail); - } - if (settings.settings.delete) { - var _btnDeleteDetail = jQuery(''); - _btnDeleteDetail.attr('data-route', settings.url); - _buttons.push(_btnDeleteDetail); - } - } else { - var _btnDeleteDetail = jQuery(''); - _btnDeleteDetail.attr('data-route', settings.url); - _buttons.push(_btnDeleteDetail); - } - } - - var _group = jQuery('
    '); - _group.append(_buttons); - - return _group; - }, - events: { - - }, - editRow: function (e) { - e.preventDefault(); - }, - render: function () { - var _html = this.template(this.model.toJSON()); - this.$el.html(_html); - this.$el.data('model', this.model); - this.$el.find('button.btn-edit').click(function (e) { - e.stopPropagation(); - - var $scope = angular.element(this).scope(); - if (settings.tab) { - $scope.$parent.edit($(this).closest('td').data('model').attributes); - } else { - $scope.edit($(this).closest('td').data('model').attributes); - } - - - }); - - this.$el.find('button.btn-delete').click(function (e) { - e.stopPropagation(); - - var _confirm = window.confirm('Deseja realmente excluir esse registro?'); - - if (_confirm) { - var $scope = angular.element(this).scope(); - if (settings.tab) { - $scope.$parent.delete($(this).closest('td').data('model').attributes); - } else { - $scope.delete($(this).closest('td').data('model').attributes); - } - } - - }); - - this.$el.find('button.btn-delete-detail').click(function (e) { - e.stopPropagation(); - - var _confirm = window.confirm('Deseja realmente excluir esse registro?'); - - if (_confirm) { - var $scope = angular.element(this).scope(); - var route = jQuery(this).attr('data-route'); - - if (settings.tab) { - $scope.$parent.deleteDetail(route, $(this).closest('td').data('model').attributes); - } else { - $scope.deleteDetail(route, $(this).closest('td').data('model').attributes); - } - } - - }); - - this.$el.find('button.btn-edit-detail').click(function (e) { - e.stopPropagation(); - - var $scope = angular.element(this).scope(); - var tab = $.parseJSON($(this).closest('.table-container').attr('tab-config')); - var row = $(this).closest('td').data('model').attributes; - var route = $(this).attr('data-route'); - - $scope.newDetail(tab, $scope.data, row.id, route); - }); - - this.delegateEvents(); - return this; - } - }); - - if (settings.settings.edit || settings.settings.delete){ - columns.push({ - name: "actions", - label: "Ações", - sortable: false, - cell: ActionCell - }); - } - - if (scope.$parent.app.helpers.isScreen('xs')) { - - columns.splice(3, 1); - } - - var rowClasses = []; - if (settings.tab == true) { - rowClasses.push('detail'); - } - if (settings.settings != undefined && !settings.settings.edit) { - rowClasses.push('cant-edit'); - } - - var ClickableRow = Backgrid.Row.extend({ - className: rowClasses.join(' '), - }); - - var _tableClass = 'table table-striped table-editable no-margin mb-sm'; - - // Join default classes and custom classes (headers.tableClass) if exists - if(settings.tableClass){ - _tableClass+=" "+settings.tableClass; - } - - var pageableGrid = new Backgrid.Grid({ - row: ClickableRow, - columns: columns, - collection: collection, - className: _tableClass - }); - - var paginator = new Backgrid.Extension.Paginator({ - - slideScale: 0.25, // Default is 0.5 - - // Whether sorting should go back to the first page - goBackFirstOnSort: false, // Default is true - - collection: collection, - - controls: { - rewind: { - label: '', - title: 'First' - }, - back: { - label: '', - title: 'Previous' - }, - forward: { - label: '', - title: 'Next' - }, - fastForward: { - label: '', - title: 'Last' - } - } - }); - - scope.$el.find('.table-container').html('').append(pageableGrid.render().$el).append(paginator.render().$el); - - setTimeout(function () { - angular.element(paginator.render().$el).click(function(){ - window.scrollTo({ - top: 100, - behavior: 'smooth' - }); - }) - },0) - - scope.$broadcast('refreshGRID', true); - } - - var oldFetch = angular.copy(pageableCRUDModel.fetch); - pageableCRUDModel.fetch = function(options, start, filter){ - - $timeout(function(){ - if (filter){ - pageableCRUDModel.state.currentPage = 1; - } - - var grid = scope.$el.attr('grid'); - var $scopeFilter = $('div[crud-filter][grid="'+grid+'"] input').scope(); - if (!$scopeFilter){ - $scopeFilter = {}; - } - - if(start){ - if (grid=="main" && $window.location.search){ - var params = {}; - decodeURIComponent($window.location.search).replace("?filter=","").split('&').forEach(function(elm, idx){ - var p = elm.split("="); - - if (p[0].split("_ini").length > 1){ - - var attr = p[0].replace("_ini",""); - if(!params[attr]){ - params[attr] = {}; - } - params[attr].ini = decodeURIComponent(p[1]); - - }else if (p[0].split("_fim").length > 1){ - - var attr = p[0].replace("_fim",""); - if(!params[attr]){ - params[attr] = {}; - } - params[attr].fim = decodeURIComponent(p[1]); - - }else{ - try { - p[1] = JSON.parse(p[1]) - // console.log('BREKA <-', p[0], p[1]); - - } catch (error) { - p[1] = p[1] - // console.log('BREKA ERROR<-', p[0], p[1]); - } - - if(typeof p[1] == "object"){ - params[p[0]] = p[1]; - }else{ - params[p[0]] = decodeURIComponent(p[1]); - } - } - }); - - // console.log(params); - if (params.p){ - $scopeFilter.data.p = params.p; - pageableCRUDModel.state.currentPage = parseInt(params.p); - } - - if (params.q){ - $scopeFilter.data.q = params.q; - // $scopeFilter.objFilter = {data:params}; - }else{ - $scopeFilter = $scopeFilter||{}; - var showBusca = false; - - Object.keys(params).forEach(function(par){ - if(par.split("_label").length > 1){ - $scopeFilter.data[par.replace("_label","")+".label"] = {id:params[par.replace("_label","")], label:params[par]}; - }else{ - // console.log('BREKA ->', params[par]) - - if (typeof(params[par])=="object"){ - for (var key in params[par]) { - if(key == "ini" || key == "fim"){ - $scopeFilter.data[par+"_"+key] = moment(params[par][key], 'DD/MM/YYYY').toDate(); - } - else if (params[par][key].id && params[par][key].label) { - $scopeFilter.data[par] = params[par] - } - else { - $scopeFilter.data[par] = $scopeFilter.data[par] || {}; - $scopeFilter.data[par][key] = params[par][key] ; - } - - } - // $scopeFilter.data[par+"_ini"] = moment(params[par].ini, 'DD/MM/YYYY').toDate(); - // $scopeFilter.data[par+"_fim"] = moment(params[par].fim, 'DD/MM/YYYY').toDate(); - }else{ - $scopeFilter.data[par] = params[par]; - } - } - if(par != 'p') showBusca = true; - }); - $scopeFilter.data['showBusca'] = showBusca; - // $scopeFilter.objFilter = {data:{filter:params}}; - } - - $scopeFilter.filterData(false); //Estava sendo recursivo isso - } - - }else{ - if (grid=="main"){ - - var str = []; - - if($scopeFilter.objFilter && $scopeFilter.objFilter.data.q){ - str.push("q="+$scopeFilter.objFilter.data.q); - } - - if($scopeFilter.objFilter && $scopeFilter.objFilter.data.filter && Object.keys($scopeFilter.objFilter.data.filter).length>0){ - for (var key in $scopeFilter.objFilter.data.filter) { - if (typeof($scopeFilter.objFilter.data.filter[key])=="object"){ - if ($scopeFilter.objFilter.data.filter[key].ini){ - str.push(key+"_ini="+$scopeFilter.objFilter.data.filter[key].ini); - } - - if ($scopeFilter.objFilter.data.filter[key].fim){ - str.push(key+"_fim="+$scopeFilter.objFilter.data.filter[key].fim); - } - - if(!$scopeFilter.objFilter.data.filter[key].ini && !$scopeFilter.objFilter.data.filter[key].fim){ - // console.log($scopeFilter.objFilter.data.filter[key]) - var objCheck = $scopeFilter.objFilter.data.filter[key]; - // console.log('objeto', objCheck); - - str.push(key+"="+JSON.stringify(objCheck)); - - } - }else{ - if (key!="p"){ - str.push(key+"="+$scopeFilter.objFilter.data.filter[key]); - } - } - } - } - - if(pageableCRUDModel.state && pageableCRUDModel.state.currentPage && pageableCRUDModel.state.currentPage!=1){ - str.push("p="+pageableCRUDModel.state.currentPage); - } - - var url = str.join("&"); - - $state.transitionTo($state.$current.name, {filter: url}, { - location: true, - inherit: true, - relative: $state.$current, - notify: false - }); - - } - } - - if($scopeFilter && $scopeFilter.objFilter && $scopeFilter.objFilter.data.q){ - options = options || {data:{}}; - options.data = options.data || {}; - options.data.q = $scopeFilter.objFilter.data.q; - - if ($scopeFilter.objFilter.data.p && start){ - options.data.page = $scopeFilter.objFilter.data.p; - pageableCRUDModel.state.currentPage = parseInt($scopeFilter.objFilter.data.p); - } - } - - if($scopeFilter.objFilter && $scopeFilter.objFilter.data.filter && Object.keys($scopeFilter.objFilter.data.filter).length>0){ - options = options || {data:{}}; - options.data = options.data || {}; - options.data.filter = $scopeFilter.objFilter.data.filter; - - if ($scopeFilter.objFilter.data.filter.p && start){ - options.data.page = $scopeFilter.objFilter.data.filter.p; - pageableCRUDModel.state.currentPage = parseInt($scopeFilter.objFilter.data.filter.p); - } - } - - oldFetch.call(pageableCRUDModel, options); - }); - } - - // jQuery($window).on('sn:resize', function () { - // createBackgrid(pageableCRUDModel); - // }); - - createBackgrid(pageableCRUDModel); - - } - - var listener = scope.$parent.$watch('headers', function (newValue, oldValue) { - if (newValue != null) { - var settings = scope.crudListSettings(); - if (settings.tab == true) { - var listenerData = scope.$parent.$watch('data', function (newValue, oldValue) { - if (newValue.id != undefined) { - render(); - listenerData(); - listener(); - } - }); - } else { - render(); - listener(); - } - - } - }); - } - } - } + 'use strict'; + + angular.module('letsAngular').directive('crudList', crudList); + + crudList.$inject = ['$window', 'jQuery', 'Backbone', 'Backgrid', 'appSettings', 'fwObjectService', '$timeout', '$state']; + + function crudList($window, jQuery, Backbone, Backgrid, appSettings, fwObjectService, $timeout, $state) { + return { + scope: { + crudListSettings: '&', + crudListDependenciesData: '&', + app: '=', + }, + controller: function ($scope) { + $scope.route = null; + + $scope.$on('refreshGRID', function (event, start, filter) { + $scope.pageableCRUDModel.fetch(null, start, filter); + }); + }, + link: function (scope, $el, attrs) { + scope.$el = $el; + + function render() { + var settings = scope.crudListSettings(); + settings.route = appSettings.API_URL + settings.url; + scope.route = settings.route; + + Backgrid.InputCellEditor.prototype.attributes.class = 'form-control input-sm'; + + var CRUDModel = Backbone.Model.extend({}); + + var paramsPageable = { + model: CRUDModel, + url: settings.route + (!settings.pagerGeneral ? '/pager' : '/pagerGeneral'), + state: { + pageSize: 20, + }, + mode: 'server', + parseRecords: function (resp, options) { + if (scope.$el[0].parseRecords && typeof scope.$el[0].parseRecords == 'function') { + return scope.$el[0].parseRecords(resp.data); + } else { + return resp.data; + } + }, + parseState: function (resp, queryParams, state, options) { + $timeout(function () { + var infoTotal = jQuery("
      "); + infoTotal.append(jQuery('
    • ').html('Registros na página: ' + resp.total_entries + ' / ' + resp.total_count)); + scope.$el.find('.table-container .backgrid-paginator ul.total-records').remove(); + scope.$el.find('.table-container .backgrid-paginator').append(infoTotal); + }); + // Sempre pegar atualizado (não causa problema em páginas customizadas) + scope.$parent.totalPager = resp.total_count; + return {totalRecords: resp.total_count}; + }, + }; + + if (settings.filterScope) { + paramsPageable.queryParams = { + scope: settings.filterScope, + }; + } + + if (settings.sort) { + paramsPageable.state.sortKey = settings.sort.sortKey; + if (settings.sort.order && settings.sort.order == 'desc') { + paramsPageable.state.order = 1; + } + } + + var PageableCRUDModel = Backbone.PageableCollection.extend(paramsPageable); + + var pageableCRUDModel = new PageableCRUDModel(), + initialCRUDModel = pageableCRUDModel; + + scope.pageableCRUDModel = pageableCRUDModel; + + function createBackgrid(collection) { + var columns = []; + + var StringFormatter = function () {}; + StringFormatter.prototype = new Backgrid.StringFormatter(); + + _.extend(StringFormatter.prototype, { + fromRaw: function (rawValue, b, c, d, e) { + return rawValue; + }, + }); + + _.each(settings.fields, function (field, idx) { + if (field.viewable) { + var cellOptions = { + name: field.name, + label: field.label, + cell: 'string', + editable: false, + headers: field, + }; + + if (field.type == 'boolean') { + cellOptions.sortable = false; + cellOptions.cell = Backgrid.Cell.extend({ + className: 'custom-situation-cell', + formatter: { + fromRaw: function (rawData, model) { + return rawData ? field.customOptions.statusTrueText : field.customOptions.statusFalseText; + }, + toRaw: function (formattedData, model) { + return 'down'; + }, + }, + }); + } else if (field.type == 'simplecolor') { + cellOptions.sortable = false; + cellOptions.cell = Backgrid.Cell.extend({ + className: 'custom-situation-cell', + initialize: function () { + Backgrid.Cell.prototype.initialize.apply(this, arguments); + }, + render: function () { + this.$el.empty(); + var formattedValue = ''; + this.$el.append(formattedValue); + this.delegateEvents(); + return this; + }, + }); + } else if (field.type == 'custom') { + var customFormatter = { + fromRaw: field.toString, + toRaw: function (formattedData, model) { + return 'down'; + }, + }; + + cellOptions.sortable = false; + var _backgridCellExtend = Backgrid.Cell.extend({ + className: 'custom-cell', + formatter: customFormatter, + }); + + _backgridCellExtend.initialize = function () { + Backgrid.Cell.prototype.initialize.apply(this, arguments); + }; + _backgridCellExtend.render = function () { + this.$el.empty(); + this.$el.data('model', this.model); + var formattedValue = customFormatter.fromRaw(this.model); + this.$el.append(formattedValue); + this.delegateEvents(); + return this; + }; + + cellOptions.cell = Backgrid.Cell.extend(_backgridCellExtend); + } else if (field.type == 'address') { + var addressFormatter = { + fromRaw: function (rawData, model) { + try { + return rawData.city + ' - ' + rawData.state; + } catch (err) { + return ''; + } + }, + toRaw: function (formattedData, model) { + return 'down'; + }, + }; + + var AddressCell = Backgrid.Cell.extend({ + className: 'address-cell', + formatter: addressFormatter, + }); + + cellOptions.cell = AddressCell; + } else if (field.type == 'float') { + if (field.customOptions && field.customOptions.currency) { + cellOptions.cell = Backgrid.Cell.extend({ + formatter: { + fromRaw: function (rawData, model) { + if (rawData) { + var rawData = rawData.toFixed(2).split('.'); + rawData[0] = 'R$ ' + rawData[0].split(/(?=(?:...)*$)/).join('.'); + return rawData.join(','); + } + }, + }, + }); + } else { + cellOptions.cell = Backgrid.NumberCell.extend({ + decimalSeparator: ',', + orderSeparator: '.', + }); + } + } else if (field.type == 'date') { + var format = 'DD/MM/YYYY'; + var modelFormat = 'YYYY/M/D'; + var displayInUTC = true; + + if (field.customOptions.monthpicker !== undefined) { + format = 'MM/YYYY'; + } + + if (field.customOptions.timestamp) { + modelFormat = 'YYYY/M/D HH:mm:ss.SSS'; + displayInUTC = false; + } + + cellOptions.cell = Backgrid.Extension.MomentCell.extend({ + modelFormat: modelFormat, + displayLang: 'pt-br', + displayFormat: format, + displayInUTC: displayInUTC, + }); + } else if (field.customOptions.enum != undefined) { + var enumOptions = []; + for (var _idx in field.customOptions.enum) { + var opt = field.customOptions.enum[_idx]; + enumOptions.push([opt, _idx]); + } + + cellOptions.cell = Backgrid.SelectCell.extend({ + optionValues: enumOptions, + }); + } else if (field.autocomplete == true) { + if (field.customOptions && field.customOptions.list != undefined) { + cellOptions.cell = Backgrid.Cell.extend({ + className: 'custom-situation-cell-select', + formatter: { + fromRaw: function (rawData, model) { + var label = ''; + field.customOptions.list.forEach(function (item) { + if (item.id == rawData) { + label = item.label; + } + }); + + return label; + }, + toRaw: function (formattedData, model) { + return 'down'; + }, + }, + }); + } else { + cellOptions.name = cellOptions.name + '.label'; + } + } + + columns.push(cellOptions); + } + }); + + var ActionCell = Backgrid.Cell.extend({ + className: 'text-right btn-column' + (settings.tab == true ? ' detail' : ''), + template: function () { + var _buttons = []; + if (!settings.tab) { + if (settings.settings.edit) { + _buttons.push(jQuery('')); + } + if (settings.settings.delete) { + _buttons.push(jQuery('')); + } + } else { + if (settings.settings) { + if (settings.settings.edit) { + var _btnEditDetail = jQuery(''); + _btnEditDetail.attr('data-route', settings.url); + _buttons.push(_btnEditDetail); + } + if (settings.settings.delete) { + var _btnDeleteDetail = jQuery(''); + _btnDeleteDetail.attr('data-route', settings.url); + _buttons.push(_btnDeleteDetail); + } + } else { + var _btnDeleteDetail = jQuery(''); + _btnDeleteDetail.attr('data-route', settings.url); + _buttons.push(_btnDeleteDetail); + } + } + + var _group = jQuery('
      '); + _group.append(_buttons); + + return _group; + }, + events: {}, + editRow: function (e) { + e.preventDefault(); + }, + render: function () { + var _html = this.template(this.model.toJSON()); + this.$el.html(_html); + this.$el.data('model', this.model); + this.$el.find('button.btn-edit').click(function (e) { + e.stopPropagation(); + + var $scope = angular.element(this).scope(); + if (settings.tab) { + $scope.$parent.edit($(this).closest('td').data('model').attributes); + } else { + $scope.edit($(this).closest('td').data('model').attributes); + } + }); + + this.$el.find('button.btn-delete').click(function (e) { + e.stopPropagation(); + + var _confirm = window.confirm('Deseja realmente excluir esse registro?'); + + if (_confirm) { + var $scope = angular.element(this).scope(); + if (settings.tab) { + $scope.$parent.delete($(this).closest('td').data('model').attributes); + } else { + $scope.delete($(this).closest('td').data('model').attributes); + } + } + }); + + this.$el.find('button.btn-delete-detail').click(function (e) { + e.stopPropagation(); + + var _confirm = window.confirm('Deseja realmente excluir esse registro?'); + + if (_confirm) { + var $scope = angular.element(this).scope(); + var route = jQuery(this).attr('data-route'); + + if (settings.tab) { + $scope.$parent.deleteDetail(route, $(this).closest('td').data('model').attributes); + } else { + $scope.deleteDetail(route, $(this).closest('td').data('model').attributes); + } + } + }); + + this.$el.find('button.btn-edit-detail').click(function (e) { + e.stopPropagation(); + + var $scope = angular.element(this).scope(); + var tab = $.parseJSON($(this).closest('.table-container').attr('tab-config')); + var row = $(this).closest('td').data('model').attributes; + var route = $(this).attr('data-route'); + + $scope.newDetail(tab, $scope.data, row.id, route); + }); + + this.delegateEvents(); + return this; + }, + }); + + if (settings.settings.edit || settings.settings.delete) { + columns.push({ + name: 'actions', + label: 'Ações', + sortable: false, + cell: ActionCell, + }); + } + + if (scope.$parent.app.helpers.isScreen('xs')) { + columns.splice(3, 1); + } + + var rowClasses = []; + if (settings.tab == true) { + rowClasses.push('detail'); + } + if (settings.settings != undefined && !settings.settings.edit) { + rowClasses.push('cant-edit'); + } + + var ClickableRow = Backgrid.Row.extend({ + className: rowClasses.join(' '), + }); + + var _tableClass = 'table table-striped table-editable no-margin mb-sm'; + + // Join default classes and custom classes (headers.tableClass) if exists + if (settings.tableClass) { + _tableClass += ' ' + settings.tableClass; + } + + var pageableGrid = new Backgrid.Grid({ + row: ClickableRow, + columns: columns, + collection: collection, + className: _tableClass, + }); + + var paginator = new Backgrid.Extension.Paginator({ + slideScale: 0.25, // Default is 0.5 + + // Whether sorting should go back to the first page + goBackFirstOnSort: false, // Default is true + + collection: collection, + + controls: { + rewind: { + label: '', + title: 'First', + }, + back: { + label: '', + title: 'Previous', + }, + forward: { + label: '', + title: 'Next', + }, + fastForward: { + label: '', + title: 'Last', + }, + }, + }); + + scope.$el.find('.table-container').html('').append(pageableGrid.render().$el).append(paginator.render().$el); + + setTimeout(function () { + angular.element(paginator.render().$el).click(function () { + window.scrollTo({ + top: 100, + behavior: 'smooth', + }); + }); + }, 0); + + scope.$broadcast('refreshGRID', true); + } + + var oldFetch = angular.copy(pageableCRUDModel.fetch); + pageableCRUDModel.fetch = function (options, start, filter) { + $timeout(function () { + if (filter) { + pageableCRUDModel.state.currentPage = 1; + } + + var grid = scope.$el.attr('grid'); + var $scopeFilter = $('div[crud-filter][grid="' + grid + '"] input').scope(); + if (!$scopeFilter) { + $scopeFilter = {}; + } + + if (start) { + if (grid == 'main' && $window.location.search) { + var params = {}; + decodeURIComponent($window.location.search) + .replace('?filter=', '') + .split('&') + .forEach(function (elm, idx) { + var p = elm.split('='); + + if (p[0].split('_ini').length > 1) { + var attr = p[0].replace(/_ini$/, ''); + if (!params[attr]) { + params[attr] = {}; + } + params[attr].ini = decodeURIComponent(p[1]); + } else if (p[0].split('_fim').length > 1) { + var attr = p[0].replace(/_fim$/, ''); + if (!params[attr]) { + params[attr] = {}; + } + params[attr].fim = decodeURIComponent(p[1]); + } else { + try { + p[1] = JSON.parse(p[1]); + // console.log('BREKA <-', p[0], p[1]); + } catch (error) { + p[1] = p[1]; + // console.log('BREKA ERROR<-', p[0], p[1]); + } + + if (typeof p[1] == 'object') { + params[p[0]] = p[1]; + } else { + params[p[0]] = decodeURIComponent(p[1]); + } + } + }); + + // console.log(params); + if (params.p) { + $scopeFilter.data.p = params.p; + pageableCRUDModel.state.currentPage = parseInt(params.p); + } + + if (params.q) { + $scopeFilter.data.q = params.q; + // $scopeFilter.objFilter = {data:params}; + } else { + $scopeFilter = $scopeFilter || {}; + var showBusca = false; + + Object.keys(params).forEach(function (par) { + if (par.split('_label').length > 1) { + $scopeFilter.data[par.replace('_label', '') + '.label'] = {id: params[par.replace('_label', '')], label: params[par]}; + } else { + // console.log('BREKA ->', params[par], params, par); + + if (typeof params[par] == 'object') { + for (var key in params[par]) { + if (key == 'ini' || key == 'fim') { + $scopeFilter.data[par + '_' + key] = moment(params[par][key], 'DD/MM/YYYY').toDate(); + if (key == 'ini') { + $scopeFilter.data[par] = $scopeFilter.data[par] ? $scopeFilter.data[par] : {}; + $scopeFilter.data[par]['startDate'] = moment(params[par][key], 'DD/MM/YYYY').toDate(); + } + if (key == 'fim') { + $scopeFilter.data[par] = $scopeFilter.data[par] ? $scopeFilter.data[par] : {}; + + $scopeFilter.data[par]['endDate'] = moment(params[par][key], 'DD/MM/YYYY').toDate(); + } + } else if (params[par][key].id && params[par][key].label) { + $scopeFilter.data[par] = params[par]; + } else { + $scopeFilter.data[par] = $scopeFilter.data[par] || {}; + $scopeFilter.data[par][key] = params[par][key]; + } + } + // $scopeFilter.data[par+"_ini"] = moment(params[par].ini, 'DD/MM/YYYY').toDate(); + // $scopeFilter.data[par+"_fim"] = moment(params[par].fim, 'DD/MM/YYYY').toDate(); + } else { + $scopeFilter.data[par] = params[par]; + } + } + if (par != 'p') showBusca = true; + }); + $scopeFilter.data['showBusca'] = showBusca; + // $scopeFilter.objFilter = {data:{filter:params}}; + } + + $scopeFilter.filterData(false); //Estava sendo recursivo isso + } + } else { + if (grid == 'main') { + var str = []; + + if ($scopeFilter.objFilter && $scopeFilter.objFilter.data.q) { + str.push('q=' + $scopeFilter.objFilter.data.q); + } + + if ($scopeFilter.objFilter && $scopeFilter.objFilter.data.filter && Object.keys($scopeFilter.objFilter.data.filter).length > 0) { + for (var key in $scopeFilter.objFilter.data.filter) { + if (typeof $scopeFilter.objFilter.data.filter[key] == 'object') { + if ($scopeFilter.objFilter.data.filter[key].ini) { + str.push(key + '_ini=' + $scopeFilter.objFilter.data.filter[key].ini); + } + + if ($scopeFilter.objFilter.data.filter[key].fim) { + str.push(key + '_fim=' + $scopeFilter.objFilter.data.filter[key].fim); + } + + if (!$scopeFilter.objFilter.data.filter[key].ini && !$scopeFilter.objFilter.data.filter[key].fim) { + // console.log($scopeFilter.objFilter.data.filter[key]) + var objCheck = $scopeFilter.objFilter.data.filter[key]; + // console.log('objeto', objCheck); + + str.push(key + '=' + JSON.stringify(objCheck)); + } + } else { + if (key != 'p') { + str.push(key + '=' + $scopeFilter.objFilter.data.filter[key]); + } + } + } + } + + if (pageableCRUDModel.state && pageableCRUDModel.state.currentPage && pageableCRUDModel.state.currentPage != 1) { + str.push('p=' + pageableCRUDModel.state.currentPage); + } + + var url = str.join('&'); + + $state.transitionTo( + $state.$current.name, + {filter: url}, + { + location: true, + inherit: true, + relative: $state.$current, + notify: false, + } + ); + } + } + + if ($scopeFilter && $scopeFilter.objFilter && $scopeFilter.objFilter.data.q) { + options = options || {data: {}}; + options.data = options.data || {}; + options.data.q = $scopeFilter.objFilter.data.q; + + if ($scopeFilter.objFilter.data.p && start) { + options.data.page = $scopeFilter.objFilter.data.p; + pageableCRUDModel.state.currentPage = parseInt($scopeFilter.objFilter.data.p); + } + } + + if ($scopeFilter.objFilter && $scopeFilter.objFilter.data.filter && Object.keys($scopeFilter.objFilter.data.filter).length > 0) { + options = options || {data: {}}; + options.data = options.data || {}; + options.data.filter = $scopeFilter.objFilter.data.filter; + + if ($scopeFilter.objFilter.data.filter.p && start) { + options.data.page = $scopeFilter.objFilter.data.filter.p; + pageableCRUDModel.state.currentPage = parseInt($scopeFilter.objFilter.data.filter.p); + } + } + + oldFetch.call(pageableCRUDModel, options); + }); + }; + + // jQuery($window).on('sn:resize', function () { + // createBackgrid(pageableCRUDModel); + // }); + + createBackgrid(pageableCRUDModel); + } + + var listener = scope.$parent.$watch('headers', function (newValue, oldValue) { + if (newValue != null) { + var settings = scope.crudListSettings(); + if (settings.tab == true) { + var listenerData = scope.$parent.$watch('data', function (newValue, oldValue) { + if (newValue.id != undefined) { + render(); + listenerData(); + listener(); + } + }); + } else { + render(); + listener(); + } + } + }); + }, + }; + } })(); diff --git a/src/directives/framework/lets-fw-datepicker-new.directive.js b/src/directives/framework/lets-fw-datepicker-new.directive.js new file mode 100644 index 0000000..84f8db1 --- /dev/null +++ b/src/directives/framework/lets-fw-datepicker-new.directive.js @@ -0,0 +1,81 @@ +(function () { + 'use strict'; + + angular.module('letsAngular').directive('newDatePicker', newDatePicker); + + newDatePicker.$inject = ['$compile', 'jQuery']; + + function newDatePicker($compile, jQuery) { + var controllerName = 'vm'; + + return { + restrict: 'A', + require: '?ngModel', + scope: true, + terminal: true, + priority: 1, + link: { + post: function postLink(scope, element, attrs, controller) { + var localscope = $(element).find('input').controller(); + try { + element.addClass('form-control'); + var tmp = JSON.parse(attrs.field); + var singleDatePicker = true; + if (typeof tmp.filter == 'object' && tmp.filter.range === true && tmp.filter._edit === true) { + singleDatePicker = false; + } + var startDate = moment().startOf('month'); + var endDate = moment(); + // tudo e muito feio daqui para baixo + var _date = !singleDatePicker ? '{date: {startDate: ' + startDate + ', endDate: ' + endDate + ' }, ' : '{'; + var options = + _date + + ' minYear: 1901,' + + " maxYear: parseInt(moment().format('YYYY'), 10)," + + " applyButtonClasses: 'btn-primary'," + + " cancelButtonClasses: 'btn-default'," + + ' showDropdowns: false,' + + ' singleDatePicker:' + + singleDatePicker + + ',' + + ' locale: {' + + " format: 'DD/MM/YYYY'," + + " separator: ' - '," + + " applyLabel: 'Aplicar'," + + " cancelLabel: 'Cancelar'," + + " daysOfWeek: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb']," + + " monthNames: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro']," + + ' },' + + ' }'; + if (!singleDatePicker) { + element.attr('placeholder', 'DD/MM/YYYY - DD/MM/YYYY'); + } else { + element.attr('placeholder', 'DD/MM/YYYY'); + } + element.attr('options', options.toString()); + element.removeAttr('new-date-picker'); + } catch (error) { + console.error(error); + } + element.on('show.daterangepicker', function ($event, picker) { + // foi necessario para inicia com algum valor quando for filtro. caso nao seja singleDatePicker + // console.log(localscope) + if (!singleDatePicker && !picker.startDate && !picker.endDate) { + picker.setStartDate(startDate); + picker.setEndDate(endDate); + // console.log(element.scope()); + } + }); + $compile(element)(scope); + }, + }, + controller: function ($scope) { + var localScope; + setTimeout(function () { + console.log($scope); + }, 100); + }, + controllerAs: controllerName, + }; + } +})(); diff --git a/src/directives/framework/lets-fw-detail-data.directive.js b/src/directives/framework/lets-fw-detail-data.directive.js index 18f663a..74b8182 100644 --- a/src/directives/framework/lets-fw-detail-data.directive.js +++ b/src/directives/framework/lets-fw-detail-data.directive.js @@ -29,6 +29,7 @@ if (field.customOptions.hour) { return moment(data[field.name]).format('DD/MM/YYYY HH:mm'); } else { + // console.log(data[field.name]) return moment(data[field.name]).format('DD/MM/YYYY'); } diff --git a/src/directives/framework/lets-fw-dynamic.directive.js b/src/directives/framework/lets-fw-dynamic.directive.js index 078b7b7..cc05977 100644 --- a/src/directives/framework/lets-fw-dynamic.directive.js +++ b/src/directives/framework/lets-fw-dynamic.directive.js @@ -1,105 +1,93 @@ (function () { - 'use strict'; - - angular.module('letsAngular') - .directive('fwDynamic', fwDynamic); - - fwDynamic.$inject = ['viaCEP', '$timeout', '$compile', 'jQuery', '$filter']; - - function fwDynamic(viaCEP, $timeout, $compile, jQuery, $filter) { - var FLOAT_REGEXP_1 = /^\$?\d+.(\d{3})*(\,\d*)$/; //Numbers like: 1.123,56 - var FLOAT_REGEXP_2 = /^\$?\d+,(\d{3})*(\.\d*)$/; //Numbers like: 1,123.56 - var FLOAT_REGEXP_3 = /^\$?\d+(\.\d*)?$/; //Numbers like: 1123.56 - var FLOAT_REGEXP_4 = /^\$?\d+(\,\d*)?$/; //Numbers like: 1123,56 - - return { - restrict: 'A', - link: { - post: function postLink(scope, $el, attrs, controller) { - if (!controller) { - controller = $el.controller('ngModel'); - } - - if (scope.field.type == 'date') { - $el.mask('99/99/9999'); - - } else if (scope.field.customOptions.cpf != undefined) { - $el.mask('999.999.999-99'); - - } else if (scope.field.customOptions.cnpj != undefined) { - $el.mask('99.999.999/9999-99'); - - } else if (scope.field.customOptions.customMask != undefined) { - $el.mask(scope.field.customOptions.customMask); - - } else if (scope.field.type == 'float') { - if (scope.field.customOptions.currency != undefined) { - $el.mask("#.##0,00", { reverse: true }); - controller.$parsers.unshift(function (value) { - return parseFloat($el.cleanVal(),10)/100; - }); - controller.$formatters.unshift(function (value) { - return $el.masked(value ? parseFloat(value).toFixed(2) : null); - }); - } else { - - } - }else if (scope.field.customOptions.documento !== undefined) { - - var cpfOrCnpj = function (val) { - return val.replace(/\D/g, '').length >= 12 ? '00.000.000/0000-00' : '000.000.000-009' ; - }, - docOptions = { - onKeyPress: function (val, e, field, options) { - field.mask(cpfOrCnpj.apply({}, arguments), options); - } - }; - - $timeout(function () { - $el.mask(cpfOrCnpj, docOptions); - }, 10); - - - } else if (scope.field.customOptions.telefone != undefined) { - var SPMaskBehavior = function (val) { - return val.replace(/\D/g, '').length === 11 ? '(00) 00000-0000' : '(00) 0000-00009'; - }, - spOptions = { - onKeyPress: function (val, e, field, options) { - field.mask(SPMaskBehavior.apply({}, arguments), options); - } - }; - - $timeout(function () { - $el.mask(SPMaskBehavior, spOptions); - }, 100); - - } else if (scope.field.customOptions.cep != undefined) { - - $el.blur(function () { - - if (!this.value){ - return false; - } - - var $scope = angular.element(this).scope(); - var dataVar = jQuery(this).parent().attr('fw-data'); - viaCEP.get(this.value).then(function (response) { - var map = $scope.field.customOptions.cep; - - $scope.data[map.address] = response.logradouro; - $scope.data[map.district] = response.bairro; - $scope.data[map.city] = response.localidade; - $scope.data[map.state] = response.uf; - $scope.data[map.ibge] = response.ibge; - $scope.data[map.gia] = response.gia; - - $scope.$emit('viacep complete', response); - }); - }); - } - } - } - } - } + 'use strict'; + + angular.module('letsAngular').directive('fwDynamic', fwDynamic); + + fwDynamic.$inject = ['viaCEP', '$timeout', '$compile', 'jQuery', '$filter']; + + function fwDynamic(viaCEP, $timeout, $compile, jQuery, $filter) { + var FLOAT_REGEXP_1 = /^\$?\d+.(\d{3})*(\,\d*)$/; //Numbers like: 1.123,56 + var FLOAT_REGEXP_2 = /^\$?\d+,(\d{3})*(\.\d*)$/; //Numbers like: 1,123.56 + var FLOAT_REGEXP_3 = /^\$?\d+(\.\d*)?$/; //Numbers like: 1123.56 + var FLOAT_REGEXP_4 = /^\$?\d+(\,\d*)?$/; //Numbers like: 1123,56 + + return { + restrict: 'A', + link: { + post: function postLink(scope, $el, attrs, controller) { + if (!controller) { + controller = $el.controller('ngModel'); + } + + if (scope.field && scope.field.type == 'date') { + $el.mask('99/99/9999'); + } else if (scope.field && scope.field.customOptions != undefined && scope.field.customOptions.cpf != undefined && scope.field.customOptions.cpf != null) { + $el.mask('999.999.999-99'); + } else if (scope.field.customOptions != undefined && scope.field.customOptions.cnpj != undefined) { + $el.mask('99.999.999/9999-99'); + } else if (scope.field.customOptions != undefined && scope.field.customOptions.customMask != undefined) { + $el.mask(scope.field.customOptions.customMask); + } else if (scope.field.customOptions != undefined && scope.field.type == 'float') { + if (scope.field.customOptions != undefined && scope.field.customOptions.currency != undefined) { + $el.mask('#.##0,00', {reverse: true}); + controller.$parsers.unshift(function (value) { + return parseFloat($el.cleanVal(), 10) / 100; + }); + controller.$formatters.unshift(function (value) { + return $el.masked(value ? parseFloat(value).toFixed(2) : null); + }); + } else { + } + } else if (scope.field.customOptions != undefined && scope.field.customOptions.documento !== undefined) { + var cpfOrCnpj = function (val) { + return val.replace(/\D/g, '').length >= 12 ? '00.000.000/0000-00' : '000.000.000-009'; + }, + docOptions = { + onKeyPress: function (val, e, field, options) { + field.mask(cpfOrCnpj.apply({}, arguments), options); + }, + }; + + $timeout(function () { + $el.mask(cpfOrCnpj, docOptions); + }, 10); + } else if (scope.field.customOptions != undefined && scope.field.customOptions.telefone != undefined) { + var SPMaskBehavior = function (val) { + return val.replace(/\D/g, '').length === 11 ? '(00) 00000-0000' : '(00) 0000-00009'; + }, + spOptions = { + onKeyPress: function (val, e, field, options) { + field.mask(SPMaskBehavior.apply({}, arguments), options); + }, + }; + + $timeout(function () { + $el.mask(SPMaskBehavior, spOptions); + }, 100); + } else if (scope.field.customOptions != undefined && scope.field.customOptions.cep != undefined) { + $el.blur(function () { + if (!this.value) { + return false; + } + + var $scope = angular.element(this).scope(); + var dataVar = jQuery(this).parent().attr('fw-data'); + viaCEP.get(this.value).then(function (response) { + var map = $scope.field.customOptions.cep; + + $scope.data[map.address] = response.logradouro; + $scope.data[map.district] = response.bairro; + $scope.data[map.city] = response.localidade; + $scope.data[map.state] = response.uf; + $scope.data[map.ibge] = response.ibge; + $scope.data[map.gia] = response.gia; + + $scope.$emit('viacep complete', response); + }); + }); + } + }, + }, + }; + } })(); diff --git a/src/directives/framework/lets-fw-input.directive.js b/src/directives/framework/lets-fw-input.directive.js index 12b7e84..9abee7c 100644 --- a/src/directives/framework/lets-fw-input.directive.js +++ b/src/directives/framework/lets-fw-input.directive.js @@ -1,95 +1,113 @@ (function () { - 'use strict'; - - angular.module('letsAngular') - .directive('fwInput', fwInput); - - fwInput.$inject = ['viaCEP', '$timeout', '$compile', 'jQuery', '$sce']; - - function fwInput(viaCEP, $timeout, $compile, jQuery, $sce) { - return { - restrict: 'E', - scope: true, - templateUrl: 'lets/views/framework/input.html', - replace: true, - link: { - - pre: function preLink(scope, $el, attrs, controller) { - - var dataVar = $el.attr('fw-data'); - - if (scope.field.customOptions.events == undefined) { - scope.field.customOptions.events = {}; - } - - scope.fieldHtml = function () { - return $sce.trustAsHtml(scope.field.toString()); - } - - if (dataVar != 'data') { - scope.data = scope[dataVar]; - } - - if(dataVar=="detail_data"){ - var detail = scope.detail_key; - - if (scope.field.autocomplete !== false){ - scope.autocomplete = function (field, val) { - return scope.autocompleteDetail(detail, field, val); - } - - scope.autocompleteSelect = function ($item, $model, $label) { - return scope.autocompleteDetailSelect(detail, $item, $model, $label); - } - } - - if (scope.field.customOptions.file != undefined) { - scope.download = function (field, id) { - return scope.downloadDetail(detail, field, id, scope.data); - } - } - } - - if (scope.field.customOptions.cep != undefined) { - - $el.find('input.main-input').blur(function () { - var $scope = angular.element(this).scope(); - - viaCEP.get(this.value).then(function (response) { - var map = $scope.field.customOptions.cep; - - $scope.data[map.address] = response.logradouro; - $scope.data[map.district] = response.bairro; - $scope.data[map.city] = response.localidade; - $scope.data[map.state] = response.uf; - - scope.$$phase || scope.$apply(); - }); - }); - } - else if (scope.field.customOptions.multiple != undefined && scope.field.customOptions.multiple == true) { - var a = $compile($el.contents())(scope); - } - - jQuery($el).on('blur', ':input[ng-model]', function (e) { - try { - if (angular.element(this).scope().field.customOptions.events.blur != undefined) { - angular.element(this).scope().field.customOptions.events.blur.call(this, e); - } - } - catch (e) { - } - - - }); - - scope.isEmpty = function (obj) { - return Object.keys(obj).length; - } - } - - } - - } - } + 'use strict'; + + angular.module('letsAngular').directive('fwInput', fwInput); + + fwInput.$inject = ['viaCEP', '$timeout', '$compile', 'jQuery', '$sce']; + + function fwInput(viaCEP, $timeout, $compile, jQuery, $sce) { + return { + restrict: 'E', + scope: true, + templateUrl: 'lets/views/framework/input.html', + replace: true, + link: { + pre: function preLink(scope, $el, attrs, controller) { + var dataVar = $el.attr('fw-data'); + + if (scope.field && scope.field.customOptions && typeof scope.field.customOptions == 'object' && !scope.field.customOptions.events) { + scope.field.customOptions['events'] = {}; + } + + scope.fieldHtml = function () { + return $sce.trustAsHtml(scope.field.toString()); + }; + + if (dataVar != 'data') { + scope.data = scope[dataVar]; + } + // console.log('scopes', scope, dataVar); + + if (dataVar == 'detail_data') { + var detail = scope.detail_key; + + if (scope.field && scope.field.autocomplete !== false) { + scope.autocomplete = function (field, val) { + return scope.autocompleteDetail(detail, field, val); + }; + + scope.autocompleteSelect = function ($item, $model, $label) { + return scope.autocompleteDetailSelect(detail, $item, $model, $label); + }; + } + + if (scope.field && scope.field.customOptions && scope.field.customOptions.file != undefined) { + scope.download = function (field, id) { + return scope.downloadDetail(detail, field, id, scope.data); + }; + } + } + + // if (scope.type == 'date') { + // console.log(scope, $el, attrs, controller, dataVar); + // scope.options = { + // date: {startDate: moment().subtract(1, 'years'), endDate: moment().add(1, 'years')}, + // picker: null, + // options: { + // pickerClasses: 'custom-display', //angular-daterangepicker extra + // buttonClasses: 'btn', + // applyButtonClasses: 'btn-primary', + // cancelButtonClasses: 'btn-danger', + // locale: { + // separator: ' - ', + // format: 'DD/MM/YYYY', + // applyLabel: 'Aplicar', + // cancelLabel: 'Cancelar', + // daysOfWeek: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'], + // monthNames: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'], + // }, + // }, + // }; + // } + + if (scope.field && scope.field.customOptions && scope.field.customOptions.cep != undefined) { + $el.find('input.main-input').blur(function () { + var $scope = angular.element(this).scope(); + + viaCEP.get(this.value).then(function (response) { + var map = $scope.field.customOptions.cep; + + $scope.data[map.address] = response.logradouro; + $scope.data[map.district] = response.bairro; + $scope.data[map.city] = response.localidade; + $scope.data[map.state] = response.uf; + + scope.$$phase || scope.$apply(); + }); + }); + } else if (scope.field && scope.field.customOptions && scope.field.customOptions.multiple != undefined && scope.field.customOptions.multiple == true) { + var a = $compile($el.contents())(scope); + } + + jQuery($el).on('blur', ':input[ng-model]', function (e) { + try { + if (angular.element(this).scope().field.customOptions.events.blur != undefined) { + angular.element(this).scope().field.customOptions.events.blur.call(this, e); + } + } catch (e) {} + }); + + scope.openDate = function (__scope) { + // console.log(nome, nome); + // console.log({__scope: __scope}); + $('input#' + __scope.name).click(); + }; + + scope.isEmpty = function (obj) { + return Object.keys(obj).length; + }; + }, + }, + }; + } })(); diff --git a/src/lets.module.js b/src/lets.module.js index 46dd72b..7290ef9 100644 --- a/src/lets.module.js +++ b/src/lets.module.js @@ -19,7 +19,8 @@ 'ckeditor', 'thatisuday.dropzone', 'swangular', - 'angularjs-dropdown-multiselect' + 'angularjs-dropdown-multiselect', + 'daterangepicker' ]); // ---------------------------- @@ -88,4 +89,4 @@ function appConfig($stateProvider, $httpProvider) { }; -})(); \ No newline at end of file +})(); diff --git a/src/services/framework/lets-fw-auth.service.js b/src/services/framework/lets-fw-auth.service.js index 1261ba1..ccd19bc 100644 --- a/src/services/framework/lets-fw-auth.service.js +++ b/src/services/framework/lets-fw-auth.service.js @@ -64,7 +64,7 @@ $state.go('main.search'); }) .catch(function (err) { - console.debug(err); + // console.debug(err); }) // .finally(function () { // self.count--; @@ -105,4 +105,3 @@ } } })(); - \ No newline at end of file diff --git a/src/views/crud/crud-filter.html b/src/views/crud/crud-filter.html index b577821..ee5dbe7 100644 --- a/src/views/crud/crud-filter.html +++ b/src/views/crud/crud-filter.html @@ -22,7 +22,7 @@
      -
      +
      @@ -35,4 +35,4 @@
      -
      \ No newline at end of file +
    diff --git a/src/views/framework/input.html b/src/views/framework/input.html index 66735e3..550d4a9 100644 --- a/src/views/framework/input.html +++ b/src/views/framework/input.html @@ -1,200 +1,307 @@ -
    +
    + +
    +
    + R$ - -
    -
    - R$ + - + +
    +
    - + +
    + +
    -
    -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    +
    +
    - -
    - -
    + +
    +
    + + + + +
    +
      +
    • A data informada é inválida.
    • +
    +
    - -
    -
    -
    + +
    + - -
    - +
      +
    • A data informada é inválida.
    • +
    +
    -
      -
    • A data informada é inválida.
    • -
    -
    + +
    + - -
    - +
      +
    • O horário informado é inválido.
    • +
    +
    -
      -
    • O horário informado é inválido.
    • -
    -
    + +
    +
    +
    +
    + + {{ f.progress + '%' }} + {{ f.name }} + {{ f.newName }} + + +
    +
    + + + + + +
    +
    - -
    -
    -
    -
    - - {{f.progress + '%'}} - {{f.name}} - {{f.newName}} - - -
    + + -
    - - - - - -
    -
    + +
    + +
    - - + +
    + +
    - -
    - -
    + +
    + +
    - -
    - -
    + +
    +
    +
    + + +
    +
    +
    - -
    - -
    - - -
    -
    -
    - - -
    -
    -
    - - -
    - -
    - -
    + +
    + +
    - - - -
    -
    - - - -
    -
    - - - - -
    -
    + buttonClasses: 'btn btn-default fw-multiselect-button'}" + selected-model="msmodel" + ng-model="data[msmodel]" + >
    + + + +
    +
    - -
    -
    - -
    -
    -
    - - - - -
    - -
    -
    - - - - - - - - - - - - - -
    - {{column.label}} -
    - {{data[column.name]}} -
    -
    -
    - -
    -
    + +
    +
    + + + + +
    +
    -
    \ No newline at end of file + +
    +
    + +
    +
    +
    + + + + +
    + +
    +
    + + + + + + + + + + + + + +
    + {{ column.label }} +
    + {{ data[column.name] }} +
    +
    +
    + +
    +
    +