diff --git a/client/auth/src/auth.js b/client/auth/src/auth.js index 8b7c022dd..d15aa496a 100644 --- a/client/auth/src/auth.js +++ b/client/auth/src/auth.js @@ -1,3 +1,2 @@ -import './ngModule'; -import './config'; +import './module'; import './login/login'; diff --git a/client/auth/src/login/login.js b/client/auth/src/login/login.js index 22783f9ab..7f587e58c 100644 --- a/client/auth/src/login/login.js +++ b/client/auth/src/login/login.js @@ -1,4 +1,4 @@ -import ngModule from '../ngModule'; +import ngModule from '../module'; import './style.scss'; export default class Controller { diff --git a/client/auth/src/login/style.scss b/client/auth/src/login/style.scss index 8f1df6705..d152c84ba 100644 --- a/client/auth/src/login/style.scss +++ b/client/auth/src/login/style.scss @@ -12,7 +12,7 @@ vn-login > div { .box-wrapper { position: relative; - max-width: 22em; + max-width: 19em; margin: auto; height: inherit; } diff --git a/client/auth/src/config.js b/client/auth/src/module.js similarity index 74% rename from client/auth/src/config.js rename to client/auth/src/module.js index 61c73ebc3..8339bc998 100644 --- a/client/auth/src/config.js +++ b/client/auth/src/module.js @@ -1,4 +1,8 @@ -import ngModule from './ngModule'; +import {ng} from 'vendor'; +import 'core'; + +let ngModule = ng.module('vnAuth', ['vnCore']); +export default ngModule; config.$inject = ['$translatePartialLoaderProvider', '$httpProvider']; export function config($translatePartialLoaderProvider, $httpProvider) { diff --git a/client/auth/src/ngModule.js b/client/auth/src/ngModule.js deleted file mode 100644 index 657afe9fc..000000000 --- a/client/auth/src/ngModule.js +++ /dev/null @@ -1,5 +0,0 @@ -import {ng} from 'vendor'; -import 'core'; - -let ngModule = ng.module('vnAuth', ['vnCore']); -export default ngModule; diff --git a/client/client/src/billing-data/locale/es.yml b/client/client/src/billing-data/locale/es.yml index 5698aaa0e..cc32fc52e 100644 --- a/client/client/src/billing-data/locale/es.yml +++ b/client/client/src/billing-data/locale/es.yml @@ -4,8 +4,6 @@ No: No Yes, notify: Sí, notificar Notification sent!: ¡Notificación enviada! Notification error: Error al enviar notificación -You changes the equivalent tax: Has cambiado el recargo de equivalencia -Do you want to spread the change to their consignees?: ¿Deseas propagar el cambio a sus consignatarios? Yes, propagate: Si, propagar Equivalent tax spreaded: Recargo de equivalencia propagado Invoice by address: Facturar por consignatario diff --git a/client/client/src/card/card.html b/client/client/src/card/card.html index 623bdfbc4..9894bcbb5 100644 --- a/client/client/src/card/card.html +++ b/client/client/src/card/card.html @@ -6,7 +6,7 @@ - + diff --git a/client/client/src/credit-list/credit-list.js b/client/client/src/credit-list/credit-list.js index 613a6eb30..b545df2da 100644 --- a/client/client/src/credit-list/credit-list.js +++ b/client/client/src/credit-list/credit-list.js @@ -1,5 +1,5 @@ import ngModule from '../module'; -import FilterClientList from '../filterClientList'; +import FilterClientList from '../filter-client-list'; ngModule.component('vnClientCreditList', { template: require('./credit-list.html'), diff --git a/client/client/src/descriptor/descriptor.html b/client/client/src/descriptor/descriptor.html index bf1a99337..e9b776ecd 100644 --- a/client/client/src/descriptor/descriptor.html +++ b/client/client/src/descriptor/descriptor.html @@ -1,18 +1,20 @@ - - - person - - - - - {{::title}}: - - {{$ctrl.client[field] || 0 | number:2}} € - {{$ctrl.client[field]}} - - - - - +
+ person +
+
+
{{$ctrl.client.name}}
+
+ Id {{$ctrl.client.id}} +
+
+ Phone {{$ctrl.client.phone | phone}} +
+
+ Credit {{$ctrl.client.credit | number:2}}€ +
+
+ Secured credit {{$ctrl.client.creditInsurance || 0 | number:2}}€ +
+
diff --git a/client/client/src/descriptor/descriptor.js b/client/client/src/descriptor/descriptor.js index ec70d0fa1..ab29245ae 100644 --- a/client/client/src/descriptor/descriptor.js +++ b/client/client/src/descriptor/descriptor.js @@ -1,32 +1,9 @@ import ngModule from '../module'; +import './style.scss'; -export default class Controller { - constructor($translate) { - this.$translate = $translate; - // CLient fields to display - this.fields = ['id', 'name', 'phone', 'credit', 'creditInsurance']; - this.fieldsToShow = {}; - } - - // concat 2 Arrays without duplicates - _concatFields(a, b) { - return a.concat(b.filter(item => a.indexOf(item) < 0)); - } - - $onInit() { - let fields = (this.moreFields && this.moreFields instanceof Array) ? this._concatFields(this.fields, this.moreFields) : this.fields; - fields.forEach(field => { - this.fieldsToShow[field] = this.$translate.instant(field); - }); - } -} -Controller.$inject = ['$translate']; - -ngModule.component('vnDescriptor', { +ngModule.component('vnClientDescriptor', { template: require('./descriptor.html'), - controller: Controller, bindings: { - client: '<', - moreFields: ' { - describe('Component vnDescriptor', () => { - let $componentController; - let $translate; - let controller; - - beforeEach(() => { - angular.mock.module('client'); - }); - - beforeEach(angular.mock.inject((_$componentController_, _$translate_) => { - $componentController = _$componentController_; - $translate = _$translate_; - controller = $componentController('vnDescriptor', {$translate: $translate}); - })); - - describe('onInit()', () => { - it('should create Object with basic fields', () => { - controller.client = { - id: 1, - name: "Peter Parker", - phone: null, - mobile: "666666", - credit: 300, - creditInsurance: null - }; - controller.$onInit(); - - expect(controller.fieldsToShow.id).toBe('id'); - }); - }); - }); -}); diff --git a/client/client/src/descriptor/style.scss b/client/client/src/descriptor/style.scss new file mode 100644 index 000000000..b702e945c --- /dev/null +++ b/client/client/src/descriptor/style.scss @@ -0,0 +1,6 @@ +vn-client-descriptor { + .data span { + font-size: .9em; + color: #666; + } +} \ No newline at end of file diff --git a/client/client/src/filterClientList.js b/client/client/src/filter-client-list.js similarity index 81% rename from client/client/src/filterClientList.js rename to client/client/src/filter-client-list.js index e4946354a..6e6b007cb 100644 --- a/client/client/src/filterClientList.js +++ b/client/client/src/filter-client-list.js @@ -1,4 +1,5 @@ -import FilterList from '../../core/src/lib/filterList'; +import FilterList from 'core/src/lib/filter-list'; + export default class FilterClientList extends FilterList { constructor($scope, $timeout, $state) { super($scope, $timeout, $state); diff --git a/client/client/src/fiscal-data/fiscal-data.html b/client/client/src/fiscal-data/fiscal-data.html index a9de01bf8..172d9305e 100644 --- a/client/client/src/fiscal-data/fiscal-data.html +++ b/client/client/src/fiscal-data/fiscal-data.html @@ -10,17 +10,49 @@ Fiscal data - - - + + + + + + - - + + + + - - + + - - + + - + + - + + - + + - + + - + + @@ -67,17 +124,9 @@ - - - - You changes the equivalen - Do you want to spread the change to their consig - - - - - - - \ No newline at end of file + diff --git a/client/client/src/fiscal-data/locale/es.yml b/client/client/src/fiscal-data/locale/es.yml new file mode 100644 index 000000000..a31826cdd --- /dev/null +++ b/client/client/src/fiscal-data/locale/es.yml @@ -0,0 +1,4 @@ +No: No +Yes, notify: Sí, notificar +You changed the equalization tax: Has cambiado el recargo de equivalencia +Do you want to spread the change: ¿Deseas propagar el cambio a sus consignatarios? \ No newline at end of file diff --git a/client/client/src/greuge-list/greuge-list.js b/client/client/src/greuge-list/greuge-list.js index 0e91db0c7..9bb863721 100644 --- a/client/client/src/greuge-list/greuge-list.js +++ b/client/client/src/greuge-list/greuge-list.js @@ -1,5 +1,5 @@ import ngModule from '../module'; -import FilterClientList from '../filterClientList'; +import FilterClientList from '../filter-client-list'; ngModule.component('vnClientGreugeList', { template: require('./greuge-list.html'), diff --git a/client/client/src/index/index.html b/client/client/src/index/index.html index ba40c663b..c8949c531 100644 --- a/client/client/src/index/index.html +++ b/client/client/src/index/index.html @@ -1,6 +1,6 @@
-
+
+ ignore-keys = "['page', 'size', 'search']"> - + +
diff --git a/client/client/src/index/index.js b/client/client/src/index/index.js index d07b12549..f78524e6b 100644 --- a/client/client/src/index/index.js +++ b/client/client/src/index/index.js @@ -1,5 +1,5 @@ import ngModule from '../module'; -import './style.css'; +import './style.scss'; import './item-client'; export default class Controller { diff --git a/client/client/src/index/item-client.html b/client/client/src/index/item-client.html index 05cf2f614..9d39c4e15 100644 --- a/client/client/src/index/item-client.html +++ b/client/client/src/index/item-client.html @@ -1,7 +1,7 @@ -
{{::$ctrl.client.name}}
-
Client id: {{::$ctrl.client.id}}
-
Phone: {{::$ctrl.client.phone | phone}}
-
Town/City: {{::$ctrl.client.city}}
-
Email: {{::$ctrl.client.email}}
+
{{::$ctrl.client.name}}
+
Id {{::$ctrl.client.id}}
+
Phone {{::$ctrl.client.phone | phone}}
+
Town/City {{::$ctrl.client.city}}
+
Email {{::$ctrl.client.email}}
diff --git a/client/client/src/index/style.css b/client/client/src/index/style.css deleted file mode 100644 index 123a0bf97..000000000 --- a/client/client/src/index/style.css +++ /dev/null @@ -1,16 +0,0 @@ -vn-item-client { - display: block; -} -vn-item-client a { - display: block; - text-decoration: none; - color: inherit; -} -vn-item-client a:hover { - color: white; - background-color: #424242; -} - -.vn-item-client-name { - font-family: vn-font-bold; -} diff --git a/client/client/src/index/style.scss b/client/client/src/index/style.scss new file mode 100644 index 000000000..126b5a078 --- /dev/null +++ b/client/client/src/index/style.scss @@ -0,0 +1,20 @@ +vn-item-client { + display: block; + + a { + display: block; + text-decoration: none; + color: inherit; + } + a:hover { + color: white; + background-color: #424242; + } + span { + font-size: .9em; + color: #666; + } + a:hover span { + color: #aaa; + } +} \ No newline at end of file diff --git a/client/client/src/mandate/mandate.js b/client/client/src/mandate/mandate.js index e48222ce6..f21f83d28 100644 --- a/client/client/src/mandate/mandate.js +++ b/client/client/src/mandate/mandate.js @@ -1,5 +1,5 @@ import ngModule from '../module'; -import FilterClientList from '../filterClientList'; +import FilterClientList from '../filter-client-list'; ngModule.component('vnClientMandate', { template: require('./mandate.html'), diff --git a/client/client/src/notes/notes.html b/client/client/src/notes/notes.html index 0b29a5d7f..7fdb6ec6b 100644 --- a/client/client/src/notes/notes.html +++ b/client/client/src/notes/notes.html @@ -5,13 +5,13 @@ ng-repeat="n in $ctrl.observations" pad-small border-solid border-radius - margin-small-bottom style="align-items: center;"> - - {{::n.worker.firstName}} {{::n.worker.name}} + margin-small-bottom> + + {{::n.worker.firstName}} {{::n.worker.name}} {{::n.created | date:'dd/MM/yyyy HH:mm'}} - {{::n.text}} + {{::n.text}} diff --git a/client/core/src/button/button.js b/client/core/src/button/button.js deleted file mode 100644 index 727633999..000000000 --- a/client/core/src/button/button.js +++ /dev/null @@ -1,18 +0,0 @@ -import {module as _module} from '../module'; -import * as resolveFactory from '../lib/resolveDefaultComponents'; -import * as util from '../lib/util'; - -const _NAME = 'button'; -export const NAME = util.getName(_NAME); - -directive.$inject = [resolveFactory.NAME]; -export function directive(resolve) { - return { - restrict: 'E', - template: function(_, attr) { - return resolve.getTemplate(_NAME, attr); - } - }; -} - -_module.directive(NAME, directive); diff --git a/client/core/src/button/button.mdl.js b/client/core/src/button/button.mdl.js deleted file mode 100644 index 104f75b06..000000000 --- a/client/core/src/button/button.mdl.js +++ /dev/null @@ -1,21 +0,0 @@ -import {module as _module} from '../module'; -import * as util from '../lib/util'; -import * as constant from '../lib/constants'; -import template from './button.mdl.html'; - -const _NAME = 'button'; -export const NAME = util.getFactoryName(_NAME + constant.MATERIAL_DESIGN_FRAMEWORK); - -export function factory() { - return { - template: template, - default: { - label: 'Submit', - className: 'mdl-button mdl-js-button mdl-button--raised mdl-button--colored', - enabled: 'true', - typeName: 'button' - } - }; -} - -_module.factory(NAME, factory); diff --git a/client/core/src/card/card.js b/client/core/src/card/card.js deleted file mode 100644 index 50aad3a2b..000000000 --- a/client/core/src/card/card.js +++ /dev/null @@ -1,21 +0,0 @@ -import {module as _module} from '../module'; -import * as resolveFactory from '../lib/resolveDefaultComponents'; -import * as util from '../lib/util'; -require('./style.css'); - -const _NAME = 'card'; -export const NAME = util.getName(_NAME); - -directive.$inject = [resolveFactory.NAME]; -export function directive(resolve) { - return { - restrict: 'E', - transclude: true, - template: function(_, attr) { - return resolve.getTemplate(_NAME, attr); - } - }; -} - -_module.directive(NAME, directive); - diff --git a/client/core/src/card/card.mdl.js b/client/core/src/card/card.mdl.js deleted file mode 100644 index 01189b4b4..000000000 --- a/client/core/src/card/card.mdl.js +++ /dev/null @@ -1,16 +0,0 @@ -import {module as _module} from '../module'; -import * as util from '../lib/util'; -import * as constant from '../lib/constants'; -import template from './card.mdl.html'; - -const _NAME = 'card'; - -export const NAME = util.getFactoryName(_NAME + constant.MATERIAL_DESIGN_FRAMEWORK); - -export function factory() { - return { - template: template - }; -} - -_module.factory(NAME, factory); diff --git a/client/core/src/check/check.js b/client/core/src/check/check.js deleted file mode 100644 index aea298be9..000000000 --- a/client/core/src/check/check.js +++ /dev/null @@ -1,29 +0,0 @@ -import {module as _module} from '../module'; -import * as resolveFactory from '../lib/resolveDefaultComponents'; -import * as normalizerFactory from '../lib/inputAttrsNormalizer'; -import * as util from '../lib/util'; -import './style.css'; - -const _NAME = 'check'; -export const NAME = util.getName(_NAME); - -directive.$inject = [resolveFactory.NAME, normalizerFactory.NAME]; -export function directive(resolve, normalizer) { - return { - restrict: 'E', - template: function(_, attrs) { - normalizer.normalize(attrs); - return resolve.getTemplate(_NAME, attrs); - }, - link: function(scope, element, attrs) { - scope.$watch(attrs.model, () => { - let mdlField = element[0].firstChild.MaterialCheckbox; - if (mdlField) - mdlField.updateClasses_(); - }); - componentHandler.upgradeElement(element[0].firstChild); - } - }; -} - -_module.directive(NAME, directive); diff --git a/client/core/src/check/check.mdl.html b/client/core/src/check/check.mdl.html deleted file mode 100644 index 9e206cf8f..000000000 --- a/client/core/src/check/check.mdl.html +++ /dev/null @@ -1,4 +0,0 @@ - diff --git a/client/core/src/check/check.mdl.js b/client/core/src/check/check.mdl.js deleted file mode 100644 index 757efaa08..000000000 --- a/client/core/src/check/check.mdl.js +++ /dev/null @@ -1,21 +0,0 @@ -import {module as _module} from '../module'; -import * as util from '../lib/util'; -import * as constant from '../lib/constants'; -import template from './check.mdl.html'; - -const _NAME = 'check'; -const DEFAULT_CLASS = 'mdl-checkbox__input'; - -export const NAME = util.getFactoryName(_NAME + constant.MATERIAL_DESIGN_FRAMEWORK); - -export function factory() { - return { - template: template, - default: { - enabled: 'true', - className: DEFAULT_CLASS - } - }; -} - -_module.factory(NAME, factory); diff --git a/client/core/src/combo/combo.js b/client/core/src/combo/combo.js deleted file mode 100644 index 12663ea2a..000000000 --- a/client/core/src/combo/combo.js +++ /dev/null @@ -1,28 +0,0 @@ -import {module as _module} from '../module'; -import * as resolveFactory from '../lib/resolveDefaultComponents'; -import * as normalizerFactory from '../lib/inputAttrsNormalizer'; -import * as util from '../lib/util'; - -const _NAME = 'combo'; -export const NAME = util.getName(_NAME); - -directive.$inject = [resolveFactory.NAME, normalizerFactory.NAME]; -export function directive(resolve, normalizer) { - return { - restrict: 'E', - transclude: true, - template: function(_, attrs) { - normalizer.normalize(attrs); - return resolve.getTemplate(_NAME, attrs); - }, - link: function(scope, element, attrs) { - scope.$watch(attrs.model, () => { - let mdlField = element[0].firstChild.MaterialTextfield; - if (mdlField) - mdlField.updateClasses_(); - }); - componentHandler.upgradeElement(element[0].firstChild); - } - }; -} -_module.directive(NAME, directive); diff --git a/client/core/src/combo/combo.mdl.js b/client/core/src/combo/combo.mdl.js deleted file mode 100644 index 48fd834f3..000000000 --- a/client/core/src/combo/combo.mdl.js +++ /dev/null @@ -1,14 +0,0 @@ -import {module} from '../module'; -import template from './combo.mdl.html'; - -export const NAME = 'vnComboMdlFactory'; -export function factory() { - return { - template: template, - default: { - label: 'Label', - enabled: 'enabled' - } - }; -} -module.factory(NAME, factory); diff --git a/client/core/src/components.js b/client/core/src/components.js deleted file mode 100644 index 82a90196c..000000000 --- a/client/core/src/components.js +++ /dev/null @@ -1,46 +0,0 @@ -import './mdl-override.css'; -import './styles/fonts/mdi-override.css'; - -import './textfield/textfield'; -import './watcher/watcher'; -import './paging/paging'; -import './icon/icon'; -import './autocomplete/autocomplete'; -import './popover/popover'; -import './dialog/dialog'; - -import './confirm/confirm'; -import './title/title'; -import './subtitle/subtitle'; -import './spinner/spinner'; -import './snackbar/snackbar'; -import './tooltip/tooltip'; -import './icon-menu/icon-menu'; -import './drop-down/drop-down'; -import './column-header/column-header'; -import './grid-header/grid-header'; -import './multi-check/multi-check'; -import './datePicker/datePicker'; - -export {NAME as BUTTON, directive as ButtonDirective} from './button/button'; -export {NAME as BUTTON_MDL, factory as buttonMdl} from './button/button.mdl'; -export {NAME as CHECK, directive as CheckDirective} from './check/check'; -export {NAME as CHECK_MDL, factory as checknMdl} from './check/check.mdl'; -export {NAME as RADIO, directive as RadioDirective} from './radio/radio'; -export {NAME as RADIO_MDL, factory as radionMdl} from './radio/radio.mdl'; -export {NAME as TEXTAREA, directive as TextareaDirective} from './textarea/textarea'; -export {NAME as TEXTAREA_MDL, factory as textareaMdl} from './textarea/textarea.mdl'; -export {NAME as LABEL, directive as LabelDirective} from './label/label'; -export {NAME as LABEL_MDL, factory as labelMdl} from './label/label.mdl'; -export {NAME as ICON_BUTTON, directive as IconButtonDirective} from './icon-button/icon-button'; - -export {NAME as SUBMIT, directive as SubmitDirective} from './submit/submit'; -export {NAME as SUBMIT_MDL, factory as submitMdl} from './submit/submit.mdl'; -export {NAME as COMBO, directive as ComboDirective} from './combo/combo'; -export {NAME as COMBO_MDL, factory as comboMdl} from './combo/combo.mdl'; -export {NAME as CARD, directive as CardDirective} from './card/card'; -export {NAME as CARD_MDL, factory as cardMdl} from './card/card.mdl'; -export {NAME as SWITCH, directive as SwitchDirective} from './switch/switch'; -export {NAME as SWITCH_MDL, factory as switchdMdl} from './switch/switch.mdl'; -export {NAME as FLOATBUTTON, directive as FloatButtonDirective} from './floatbutton/floatbutton'; -export {NAME as FLOATBUTTON_MDL, factory as floatButtondMdl} from './floatbutton/floatbutton.mdl'; diff --git a/client/core/src/autocomplete/autocomplete.html b/client/core/src/components/autocomplete/autocomplete.html similarity index 100% rename from client/core/src/autocomplete/autocomplete.html rename to client/core/src/components/autocomplete/autocomplete.html diff --git a/client/core/src/autocomplete/autocomplete.js b/client/core/src/components/autocomplete/autocomplete.js similarity index 98% rename from client/core/src/autocomplete/autocomplete.js rename to client/core/src/components/autocomplete/autocomplete.js index 528c8fadf..2dc37b659 100644 --- a/client/core/src/autocomplete/autocomplete.js +++ b/client/core/src/components/autocomplete/autocomplete.js @@ -1,6 +1,6 @@ -import {module} from '../module'; -import Component from '../lib/component'; -import copyObject from '../lib/copy'; +import ngModule from '../../module'; +import Component from '../../lib/component'; +import copyObject from '../../lib/copy'; import './style.scss'; class Autocomplete extends Component { @@ -357,7 +357,7 @@ class Autocomplete extends Component { } Autocomplete.$inject = ['$element', '$scope', '$http', '$timeout', '$filter']; -module.component('vnAutocomplete', { +ngModule.component('vnAutocomplete', { template: require('./autocomplete.html'), controller: Autocomplete, bindings: { diff --git a/client/core/src/autocomplete/autocomplete.spec.js b/client/core/src/components/autocomplete/autocomplete.spec.js similarity index 100% rename from client/core/src/autocomplete/autocomplete.spec.js rename to client/core/src/components/autocomplete/autocomplete.spec.js diff --git a/client/core/src/autocomplete/style.scss b/client/core/src/components/autocomplete/style.scss similarity index 100% rename from client/core/src/autocomplete/style.scss rename to client/core/src/components/autocomplete/style.scss diff --git a/client/core/src/button/button.mdl.html b/client/core/src/components/button/button.html similarity index 100% rename from client/core/src/button/button.mdl.html rename to client/core/src/components/button/button.html diff --git a/client/core/src/components/button/button.js b/client/core/src/components/button/button.js new file mode 100644 index 000000000..6247bb77b --- /dev/null +++ b/client/core/src/components/button/button.js @@ -0,0 +1,17 @@ +import ngModule from '../../module'; +import template from './button.html'; + +directive.$inject = ['vnTemplate']; +export default function directive(vnTemplate) { + return { + restrict: 'E', + template: (_, $attrs) => + vnTemplate.get(template, $attrs, { + label: 'Submit', + className: 'mdl-button mdl-js-button mdl-button--raised mdl-button--colored', + enabled: 'true', + typeName: 'button' + }) + }; +} +ngModule.directive('vnButton', directive); diff --git a/client/core/src/card/card.mdl.html b/client/core/src/components/card/card.html similarity index 100% rename from client/core/src/card/card.mdl.html rename to client/core/src/components/card/card.html diff --git a/client/core/src/components/card/card.js b/client/core/src/components/card/card.js new file mode 100644 index 000000000..25a6802a8 --- /dev/null +++ b/client/core/src/components/card/card.js @@ -0,0 +1,14 @@ +import ngModule from '../../module'; +import template from './card.html'; +require('./style.css'); + +directive.$inject = ['vnTemplate']; +export default function directive(vnTemplate) { + return { + restrict: 'E', + transclude: true, + template: (_, $attrs) => + vnTemplate.get(template, $attrs) + }; +} +ngModule.directive('vnCard', directive); diff --git a/client/core/src/card/style.css b/client/core/src/components/card/style.css similarity index 100% rename from client/core/src/card/style.css rename to client/core/src/components/card/style.css diff --git a/client/core/src/components/check/check.html b/client/core/src/components/check/check.html new file mode 100644 index 000000000..b261a53a7 --- /dev/null +++ b/client/core/src/components/check/check.html @@ -0,0 +1,4 @@ + diff --git a/client/core/src/components/check/check.js b/client/core/src/components/check/check.js new file mode 100644 index 000000000..5b1a276d6 --- /dev/null +++ b/client/core/src/components/check/check.js @@ -0,0 +1,50 @@ +import ngModule from '../../module'; +import Input from '../../lib/input'; +import './style.scss'; + +export default class Controller extends Input { + constructor($element, $scope) { + super($element, $scope); + componentHandler.upgradeElement(this.element.firstChild); + this.mdlElement = this.element.firstChild.MaterialCheckbox; + this.input.addEventListener('change', () => this.onChange()); + } + set field(value) { + this.input.checked = value == true; + this.mdlUpdate(); + } + get field() { + return this.input.checked == true; + } + $onInit() { + if (this.model) { + this.model.$render = () => { + this.input.checked = this.model.$viewValue || false; + this.mdlUpdate(); + }; + this.$element.on('blur keyup change', () => { + this.$.$evalAsync(() => { + this.model.$setViewValue(this.input.checked); + }); + }); + } + } + onChange() { + this.$.$applyAsync(); + } +} +Controller.$inject = ['$element', '$scope', '$injector']; + +ngModule.component('vnCheck', { + template: require('./check.html'), + controller: Controller, + require: { + model: '?ngModel' + }, + bindings: { + field: '=?', + label: '@?', + disabled: ' -
diff --git a/client/core/src/components/combo/combo.js b/client/core/src/components/combo/combo.js new file mode 100644 index 000000000..94c493379 --- /dev/null +++ b/client/core/src/components/combo/combo.js @@ -0,0 +1,25 @@ +import ngModule from '../../module'; +import template from './combo.html'; + +directive.$inject = ['vnTemplate']; +export function directive(vnTemplate) { + return { + restrict: 'E', + transclude: true, + template: (_, $attrs) => + vnTemplate.getNormalized(template, $attrs, { + label: 'Label', + enabled: 'enabled', + class: 'mdl-textfield__input' + }), + link: function(scope, element, attrs) { + scope.$watch(attrs.model, () => { + let mdlField = element[0].firstChild.MaterialTextfield; + if (mdlField) + mdlField.updateClasses_(); + }); + componentHandler.upgradeElement(element[0].firstChild); + } + }; +} +ngModule.directive('vnCombo', directive); diff --git a/client/core/src/confirm/confirm.html b/client/core/src/components/confirm/confirm.html similarity index 83% rename from client/core/src/confirm/confirm.html rename to client/core/src/components/confirm/confirm.html index 82b58f59a..34fdb4321 100644 --- a/client/core/src/confirm/confirm.html +++ b/client/core/src/components/confirm/confirm.html @@ -6,11 +6,11 @@
- {{$ctrl.question}} -
-
- {{$ctrl.message}} + {{::$ctrl.question}}
+ + {{::$ctrl.message}} +
diff --git a/client/core/src/confirm/confirm.js b/client/core/src/components/confirm/confirm.js similarity index 69% rename from client/core/src/confirm/confirm.js rename to client/core/src/components/confirm/confirm.js index f629fe788..cc9f56db4 100644 --- a/client/core/src/confirm/confirm.js +++ b/client/core/src/components/confirm/confirm.js @@ -1,16 +1,16 @@ -import {module} from '../module'; +import ngModule from '../../module'; import Dialog from '../dialog/dialog'; -import './style.css'; +import './style.scss'; export default class Confirm extends Dialog {} Dialog.$inject = ['$element']; -module.component('vnConfirm', { +ngModule.component('vnConfirm', { template: require('./confirm.html'), bindings: { onResponse: '&', question: '@', - message: '@' + message: '@?' }, controller: Confirm }); diff --git a/client/core/src/confirm/style.css b/client/core/src/components/confirm/style.scss similarity index 100% rename from client/core/src/confirm/style.css rename to client/core/src/components/confirm/style.scss diff --git a/client/core/src/datePicker/datePicker.html b/client/core/src/components/date-picker/date-picker.html similarity index 64% rename from client/core/src/datePicker/datePicker.html rename to client/core/src/components/date-picker/date-picker.html index 21839aa16..299d9df4b 100644 --- a/client/core/src/datePicker/datePicker.html +++ b/client/core/src/components/date-picker/date-picker.html @@ -5,8 +5,7 @@ ng-blur="$ctrl.hasFocus = false" ng-mouseenter="$ctrl.hasMouseIn = true" ng-mouseleave="$ctrl.hasMouseIn = false" - ng-click="$ctrl.onClick()" -> + ng-click="$ctrl.onClick()">
- query_builder - clear + + query_builder + + + clear +
\ No newline at end of file diff --git a/client/core/src/datePicker/datePicker.js b/client/core/src/components/date-picker/date-picker.js similarity index 97% rename from client/core/src/datePicker/datePicker.js rename to client/core/src/components/date-picker/date-picker.js index 9dfaeaf98..db5e59d6f 100644 --- a/client/core/src/datePicker/datePicker.js +++ b/client/core/src/components/date-picker/date-picker.js @@ -1,5 +1,5 @@ -import {module} from '../module'; -import Component from '../lib/component'; +import ngModule from '../../module'; +import Component from '../../lib/component'; import Flatpickr from 'vendor/src/flatpickr'; import './style.scss'; @@ -238,8 +238,8 @@ class DatePicker extends Component { } DatePicker.$inject = ['$element', '$translate', '$filter', '$timeout', '$attrs']; -module.component('vnDatePicker', { - template: require('./datePicker.html'), +ngModule.component('vnDatePicker', { + template: require('./date-picker.html'), bindings: { model: '=', label: '@?', diff --git a/client/core/src/datePicker/datePicker.spec.js b/client/core/src/components/date-picker/date-picker.spec.js similarity index 98% rename from client/core/src/datePicker/datePicker.spec.js rename to client/core/src/components/date-picker/date-picker.spec.js index 05ff49d4f..2be0c1eb4 100644 --- a/client/core/src/datePicker/datePicker.spec.js +++ b/client/core/src/components/date-picker/date-picker.spec.js @@ -1,4 +1,4 @@ -import './datePicker.js'; +import './date-picker.js'; describe('Component vnDatePicker', () => { let $componentController; diff --git a/client/core/src/datePicker/style.scss b/client/core/src/components/date-picker/style.scss similarity index 100% rename from client/core/src/datePicker/style.scss rename to client/core/src/components/date-picker/style.scss diff --git a/client/core/src/dialog/dialog.html b/client/core/src/components/dialog/dialog.html similarity index 100% rename from client/core/src/dialog/dialog.html rename to client/core/src/components/dialog/dialog.html diff --git a/client/core/src/dialog/dialog.js b/client/core/src/components/dialog/dialog.js similarity index 94% rename from client/core/src/dialog/dialog.js rename to client/core/src/components/dialog/dialog.js index a8d33b4ca..77873b380 100644 --- a/client/core/src/dialog/dialog.js +++ b/client/core/src/components/dialog/dialog.js @@ -1,5 +1,5 @@ -import {module} from '../module'; -import Component from '../lib/component'; +import ngModule from '../../module'; +import Component from '../../lib/component'; import './style.scss'; /** @@ -8,6 +8,8 @@ import './style.scss'; export default class Dialog extends Component { /** * Contructor. + * + * @param {HTMLElement} $element The HTML element object */ constructor($element) { super($element); @@ -100,7 +102,7 @@ export default class Dialog extends Component { } Dialog.$inject = ['$element']; -module.component('vnDialog', { +ngModule.component('vnDialog', { template: require('./dialog.html'), transclude: { tplBody: 'tplBody', diff --git a/client/core/src/dialog/dialog.spec.js b/client/core/src/components/dialog/dialog.spec.js similarity index 100% rename from client/core/src/dialog/dialog.spec.js rename to client/core/src/components/dialog/dialog.spec.js diff --git a/client/core/src/dialog/style.scss b/client/core/src/components/dialog/style.scss similarity index 100% rename from client/core/src/dialog/style.scss rename to client/core/src/components/dialog/style.scss diff --git a/client/core/src/drop-down/drop-down.html b/client/core/src/components/drop-down/drop-down.html similarity index 100% rename from client/core/src/drop-down/drop-down.html rename to client/core/src/components/drop-down/drop-down.html diff --git a/client/core/src/drop-down/drop-down.js b/client/core/src/components/drop-down/drop-down.js similarity index 98% rename from client/core/src/drop-down/drop-down.js rename to client/core/src/components/drop-down/drop-down.js index 5a3666651..93de8cf15 100644 --- a/client/core/src/drop-down/drop-down.js +++ b/client/core/src/components/drop-down/drop-down.js @@ -1,6 +1,6 @@ -import {module} from '../module'; +import ngModule from '../../module'; +import validKey from '../../lib/key-codes'; import './style.scss'; -import validKey from '../lib/keyCodes'; export default class DropDown { constructor($element, $filter, $timeout) { @@ -264,7 +264,7 @@ export default class DropDown { DropDown.$inject = ['$element', '$filter', '$timeout']; -module.component('vnDropDown', { +ngModule.component('vnDropDown', { template: require('./drop-down.html'), controller: DropDown, bindings: { diff --git a/client/core/src/drop-down/drop-down.spec.js b/client/core/src/components/drop-down/drop-down.spec.js similarity index 100% rename from client/core/src/drop-down/drop-down.spec.js rename to client/core/src/components/drop-down/drop-down.spec.js diff --git a/client/core/src/drop-down/style.scss b/client/core/src/components/drop-down/style.scss similarity index 100% rename from client/core/src/drop-down/style.scss rename to client/core/src/components/drop-down/style.scss diff --git a/client/core/src/floatbutton/floatbutton.mdl.html b/client/core/src/components/float-button/float-button.html similarity index 100% rename from client/core/src/floatbutton/floatbutton.mdl.html rename to client/core/src/components/float-button/float-button.html diff --git a/client/core/src/components/float-button/float-button.js b/client/core/src/components/float-button/float-button.js new file mode 100644 index 000000000..d655a721b --- /dev/null +++ b/client/core/src/components/float-button/float-button.js @@ -0,0 +1,14 @@ +import ngModule from '../../module'; +import template from './float-button.html'; + +directive.$inject = ['vnTemplate']; +export function directive(vnTemplate) { + return { + restrict: 'E', + template: (_, $attrs) => + vnTemplate.get(template, $attrs, { + className: 'mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--colored' + }) + }; +} +ngModule.directive('vnFloatButton', directive); diff --git a/client/core/src/grid-header/grid-header.html b/client/core/src/components/grid-header/grid-header.html similarity index 100% rename from client/core/src/grid-header/grid-header.html rename to client/core/src/components/grid-header/grid-header.html diff --git a/client/core/src/grid-header/grid-header.js b/client/core/src/components/grid-header/grid-header.js similarity index 87% rename from client/core/src/grid-header/grid-header.js rename to client/core/src/components/grid-header/grid-header.js index 3f8bd7292..41d96602d 100644 --- a/client/core/src/grid-header/grid-header.js +++ b/client/core/src/components/grid-header/grid-header.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import ngModule from '../../module'; import './style.scss'; export default class GridHeader { @@ -17,7 +17,7 @@ export default class GridHeader { } -module.component('vnGridHeader', { +ngModule.component('vnGridHeader', { template: require('./grid-header.html'), transclude: true, bindings: { diff --git a/client/core/src/grid-header/grid-header.spec.js b/client/core/src/components/grid-header/grid-header.spec.js similarity index 100% rename from client/core/src/grid-header/grid-header.spec.js rename to client/core/src/components/grid-header/grid-header.spec.js diff --git a/client/core/src/grid-header/style.scss b/client/core/src/components/grid-header/style.scss similarity index 100% rename from client/core/src/grid-header/style.scss rename to client/core/src/components/grid-header/style.scss diff --git a/client/core/src/components/icon-button/icon-button.html b/client/core/src/components/icon-button/icon-button.html new file mode 100644 index 000000000..fdd022710 --- /dev/null +++ b/client/core/src/components/icon-button/icon-button.html @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/client/core/src/icon-button/icon-button.js b/client/core/src/components/icon-button/icon-button.js similarity index 66% rename from client/core/src/icon-button/icon-button.js rename to client/core/src/components/icon-button/icon-button.js index 4201a37a8..c257b9da9 100644 --- a/client/core/src/icon-button/icon-button.js +++ b/client/core/src/components/icon-button/icon-button.js @@ -1,6 +1,6 @@ -import {module as _module} from '../module'; +import ngModule from '../../module'; -_module.component('vnIconButton', { +ngModule.component('vnIconButton', { template: require('./icon-button.html'), bindings: { icon: '@', diff --git a/client/core/src/icon-menu/icon-menu.html b/client/core/src/components/icon-menu/icon-menu.html similarity index 100% rename from client/core/src/icon-menu/icon-menu.html rename to client/core/src/components/icon-menu/icon-menu.html diff --git a/client/core/src/icon-menu/icon-menu.js b/client/core/src/components/icon-menu/icon-menu.js similarity index 97% rename from client/core/src/icon-menu/icon-menu.js rename to client/core/src/components/icon-menu/icon-menu.js index b36bd9448..fc0e57432 100644 --- a/client/core/src/icon-menu/icon-menu.js +++ b/client/core/src/components/icon-menu/icon-menu.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import ngModule from '../../module'; import './style.scss'; export default class IconMenu { @@ -116,10 +116,9 @@ export default class IconMenu { this.$element.unbind('focusout'); } } - IconMenu.$inject = ['$element', '$http', '$timeout']; -module.component('vnIconMenu', { +ngModule.component('vnIconMenu', { template: require('./icon-menu.html'), bindings: { url: '@?', diff --git a/client/core/src/icon-menu/icon-menu.spec.js b/client/core/src/components/icon-menu/icon-menu.spec.js similarity index 100% rename from client/core/src/icon-menu/icon-menu.spec.js rename to client/core/src/components/icon-menu/icon-menu.spec.js diff --git a/client/core/src/icon-menu/style.scss b/client/core/src/components/icon-menu/style.scss similarity index 100% rename from client/core/src/icon-menu/style.scss rename to client/core/src/components/icon-menu/style.scss diff --git a/client/core/src/icon/icon.js b/client/core/src/components/icon/icon.js similarity index 65% rename from client/core/src/icon/icon.js rename to client/core/src/components/icon/icon.js index 37055ad53..34af96deb 100644 --- a/client/core/src/icon/icon.js +++ b/client/core/src/components/icon/icon.js @@ -1,7 +1,7 @@ -import {module} from '../module'; +import ngModule from '../../module'; import './style.css'; -module.component('vnIcon', { +ngModule.component('vnIcon', { template: '{{::$ctrl.icon}}', bindings: { icon: '@' diff --git a/client/core/src/icon/style.css b/client/core/src/components/icon/style.css similarity index 100% rename from client/core/src/icon/style.css rename to client/core/src/components/icon/style.css diff --git a/client/core/src/components/index.js b/client/core/src/components/index.js new file mode 100644 index 000000000..3639b82c8 --- /dev/null +++ b/client/core/src/components/index.js @@ -0,0 +1,30 @@ +import './textfield/textfield'; +import './watcher/watcher'; +import './paging/paging'; +import './icon/icon'; +import './autocomplete/autocomplete'; +import './popover/popover'; +import './dialog/dialog'; +import './confirm/confirm'; +import './title/title'; +import './subtitle/subtitle'; +import './spinner/spinner'; +import './snackbar/snackbar'; +import './tooltip/tooltip'; +import './icon-menu/icon-menu'; +import './drop-down/drop-down'; +import './column-header/column-header'; +import './grid-header/grid-header'; +import './multi-check/multi-check'; +import './date-picker/date-picker'; +import './button/button'; +import './check/check'; +import './radio/radio'; +import './textarea/textarea'; +import './label/label'; +import './icon-button/icon-button'; +import './submit/submit'; +import './combo/combo'; +import './card/card'; +import './switch/switch'; +import './float-button/float-button'; diff --git a/client/core/src/label/label.mdl.html b/client/core/src/components/label/label.html similarity index 100% rename from client/core/src/label/label.mdl.html rename to client/core/src/components/label/label.html diff --git a/client/core/src/components/label/label.js b/client/core/src/components/label/label.js new file mode 100644 index 000000000..a556cd7b0 --- /dev/null +++ b/client/core/src/components/label/label.js @@ -0,0 +1,12 @@ +import ngModule from '../../module'; +import template from './label.html'; + +directive.$inject = ['vnTemplate']; +export default function directive(vnTemplate) { + return { + restrict: 'E', + template: (_, $attrs) => + vnTemplate.get(template, $attrs) + }; +} +ngModule.directive('vnLabel', directive); diff --git a/client/core/src/multi-check/multi-check.html b/client/core/src/components/multi-check/multi-check.html similarity index 100% rename from client/core/src/multi-check/multi-check.html rename to client/core/src/components/multi-check/multi-check.html diff --git a/client/core/src/multi-check/multi-check.js b/client/core/src/components/multi-check/multi-check.js similarity index 97% rename from client/core/src/multi-check/multi-check.js rename to client/core/src/components/multi-check/multi-check.js index 4ab7c87ce..21f60ec63 100644 --- a/client/core/src/multi-check/multi-check.js +++ b/client/core/src/components/multi-check/multi-check.js @@ -1,5 +1,6 @@ -import {module} from '../module'; +import ngModule from '../../module'; import './multi-check.scss'; + /** * Draw checkbox with a drop-down and multi options * @param {SmallInt} checkAll Primary input-check state: 0 -> uncheck, 1 -> checked, 2 -> indeterminate checked @@ -90,10 +91,9 @@ export default class MultiCheck { }, 200); } } - MultiCheck.$inject = ['$timeout']; -module.component('vnMultiCheck', { +ngModule.component('vnMultiCheck', { template: require('./multi-check.html'), controller: MultiCheck, bindings: { diff --git a/client/core/src/multi-check/multi-check.scss b/client/core/src/components/multi-check/multi-check.scss similarity index 100% rename from client/core/src/multi-check/multi-check.scss rename to client/core/src/components/multi-check/multi-check.scss diff --git a/client/core/src/multi-check/multi-check.spec.js b/client/core/src/components/multi-check/multi-check.spec.js similarity index 100% rename from client/core/src/multi-check/multi-check.spec.js rename to client/core/src/components/multi-check/multi-check.spec.js diff --git a/client/core/src/paging/paging.html b/client/core/src/components/paging/paging.html similarity index 100% rename from client/core/src/paging/paging.html rename to client/core/src/components/paging/paging.html diff --git a/client/core/src/paging/paging.js b/client/core/src/components/paging/paging.js similarity index 91% rename from client/core/src/paging/paging.js rename to client/core/src/components/paging/paging.js index 1e415b366..850b9c722 100644 --- a/client/core/src/paging/paging.js +++ b/client/core/src/components/paging/paging.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import ngModule from '../../module'; import './style.scss'; export default class Paging { @@ -45,11 +45,9 @@ export default class Paging { } } } - Paging.$inject = ['$http', '$scope']; -export const NAME = 'vnPaging'; -export const COMPONENT = { +ngModule.component('vnPaging', { template: require('./paging.html'), bindings: { index: '<', @@ -57,6 +55,4 @@ export const COMPONENT = { total: '<' }, controller: Paging -}; - -module.component(NAME, COMPONENT); +}); diff --git a/client/core/src/paging/paging.spec.js b/client/core/src/components/paging/paging.spec.js similarity index 100% rename from client/core/src/paging/paging.spec.js rename to client/core/src/components/paging/paging.spec.js diff --git a/client/core/src/paging/style.scss b/client/core/src/components/paging/style.scss similarity index 100% rename from client/core/src/paging/style.scss rename to client/core/src/components/paging/style.scss diff --git a/client/core/src/popover/popover.js b/client/core/src/components/popover/popover.js similarity index 98% rename from client/core/src/popover/popover.js rename to client/core/src/components/popover/popover.js index a635ab002..8430f037c 100644 --- a/client/core/src/popover/popover.js +++ b/client/core/src/components/popover/popover.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import ngModule from '../../module'; import './style.css'; directive.$inject = ['vnPopover']; @@ -13,8 +13,7 @@ export function directive(vnPopover) { } }; } - -module.directive('vnPopover', directive); +ngModule.directive('vnPopover', directive); export class Popover { constructor($document, $compile, $transitions) { @@ -201,7 +200,6 @@ export class Popover { this.lastTarget = event.target; } } - Popover.$inject = ['$document', '$compile', '$transitions']; -module.service('vnPopover', Popover); +ngModule.service('vnPopover', Popover); diff --git a/client/core/src/popover/style.css b/client/core/src/components/popover/style.css similarity index 100% rename from client/core/src/popover/style.css rename to client/core/src/components/popover/style.css diff --git a/client/core/src/components/radio/radio.html b/client/core/src/components/radio/radio.html new file mode 100644 index 000000000..887a97c04 --- /dev/null +++ b/client/core/src/components/radio/radio.html @@ -0,0 +1,7 @@ + +*[text]* diff --git a/client/core/src/components/radio/radio.js b/client/core/src/components/radio/radio.js new file mode 100644 index 000000000..70dbc059d --- /dev/null +++ b/client/core/src/components/radio/radio.js @@ -0,0 +1,15 @@ +import ngModule from '../../module'; +import template from './radio.html'; + +directive.$inject = ['vnTemplate']; +export default function directive(vnTemplate) { + return { + restrict: 'E', + template: (_, $attrs) => + vnTemplate.get(template, $attrs, { + enabled: 'true', + className: 'mdl-radio mdl-js-radio mdl-js-ripple-effect' + }) + }; +} +ngModule.directive('vnRadio', directive); diff --git a/client/core/src/snackbar/snackbar.html b/client/core/src/components/snackbar/snackbar.html similarity index 100% rename from client/core/src/snackbar/snackbar.html rename to client/core/src/components/snackbar/snackbar.html diff --git a/client/core/src/snackbar/snackbar.js b/client/core/src/components/snackbar/snackbar.js similarity index 88% rename from client/core/src/snackbar/snackbar.js rename to client/core/src/components/snackbar/snackbar.js index 20a7e9374..89ab60ec3 100644 --- a/client/core/src/snackbar/snackbar.js +++ b/client/core/src/components/snackbar/snackbar.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import ngModule from '../../module'; /** * A simple component to show non-obstructive notifications to the user. @@ -19,7 +19,7 @@ export default class Controller { } Controller.$inject = ['$element']; -module.component('vnSnackbar', { +ngModule.component('vnSnackbar', { template: require('./snackbar.html'), controller: Controller }); diff --git a/client/core/src/spinner/spinner.html b/client/core/src/components/spinner/spinner.html similarity index 100% rename from client/core/src/spinner/spinner.html rename to client/core/src/components/spinner/spinner.html diff --git a/client/core/src/spinner/spinner.js b/client/core/src/components/spinner/spinner.js similarity index 90% rename from client/core/src/spinner/spinner.js rename to client/core/src/components/spinner/spinner.js index ae6a69ede..ca87323d5 100644 --- a/client/core/src/spinner/spinner.js +++ b/client/core/src/components/spinner/spinner.js @@ -1,5 +1,5 @@ -import {module} from '../module'; -import Component from '../lib/component'; +import ngModule from '../../module'; +import Component from '../../lib/component'; import './style.css'; /** @@ -55,4 +55,4 @@ export const component = { }, controller: Spinner }; -module.component('vnSpinner', component); +ngModule.component('vnSpinner', component); diff --git a/client/core/src/spinner/spinner.spec.js b/client/core/src/components/spinner/spinner.spec.js similarity index 100% rename from client/core/src/spinner/spinner.spec.js rename to client/core/src/components/spinner/spinner.spec.js diff --git a/client/core/src/spinner/style.css b/client/core/src/components/spinner/style.css similarity index 100% rename from client/core/src/spinner/style.css rename to client/core/src/components/spinner/style.css diff --git a/client/core/src/components/submit/submit.html b/client/core/src/components/submit/submit.html new file mode 100644 index 000000000..378920de0 --- /dev/null +++ b/client/core/src/components/submit/submit.html @@ -0,0 +1,7 @@ + + diff --git a/client/core/src/components/submit/submit.js b/client/core/src/components/submit/submit.js new file mode 100644 index 000000000..6eb67dea8 --- /dev/null +++ b/client/core/src/components/submit/submit.js @@ -0,0 +1,16 @@ +import ngModule from '../../module'; +import template from './submit.html'; + +directive.$inject = ['vnTemplate']; +export default function directive(vnTemplate) { + return { + restrict: 'E', + template: (_, $attrs) => + vnTemplate.get(template, $attrs, { + label: 'Submit', + className: 'mdl-button mdl-js-button mdl-button--raised mdl-button--colored', + enabled: 'true' + }) + }; +} +ngModule.directive('vnSubmit', directive); diff --git a/client/core/src/subtitle/subtitle.html b/client/core/src/components/subtitle/subtitle.html similarity index 100% rename from client/core/src/subtitle/subtitle.html rename to client/core/src/components/subtitle/subtitle.html diff --git a/client/core/src/components/subtitle/subtitle.js b/client/core/src/components/subtitle/subtitle.js new file mode 100644 index 000000000..577bdf83f --- /dev/null +++ b/client/core/src/components/subtitle/subtitle.js @@ -0,0 +1,6 @@ +import ngModule from '../../module'; + +ngModule.component('vnSubtitle', { + template: require('./subtitle.html'), + transclude: true +}); diff --git a/client/core/src/switch/switch.mdl.html b/client/core/src/components/switch/switch.html similarity index 100% rename from client/core/src/switch/switch.mdl.html rename to client/core/src/components/switch/switch.html diff --git a/client/core/src/components/switch/switch.js b/client/core/src/components/switch/switch.js new file mode 100644 index 000000000..c86d6f665 --- /dev/null +++ b/client/core/src/components/switch/switch.js @@ -0,0 +1,26 @@ +import ngModule from '../../module'; + +directive.$inject = ['vnTemplate']; +export default function directive(vnTemplate) { + return { + restrict: 'E', + template: (_, $attrs) => + vnTemplate.getNormalized(template, $attrs, { + className: 'mdl-switch__input', + label: '' + }), + link: function(scope, element, attrs) { + scope.$watch(attrs.model, () => { + let mdlField = element[0].firstChild.MaterialSwitch; + if (mdlField) + mdlField.updateClasses_(); + }); + componentHandler.upgradeElement(element[0].firstChild); + } + }; +} +ngModule.directive('vnSwitch', directive); + +export function factory() { +} +ngModule.factory('vnSwitchMdlFactory', factory); diff --git a/client/core/src/components/textarea/textarea.html b/client/core/src/components/textarea/textarea.html new file mode 100644 index 000000000..04102cd5e --- /dev/null +++ b/client/core/src/components/textarea/textarea.html @@ -0,0 +1,10 @@ +
+ + +
\ No newline at end of file diff --git a/client/core/src/components/textarea/textarea.js b/client/core/src/components/textarea/textarea.js new file mode 100644 index 000000000..6bacdfc9f --- /dev/null +++ b/client/core/src/components/textarea/textarea.js @@ -0,0 +1,23 @@ +import ngModule from '../../module'; +import template from './textarea.html'; + +directive.$inject = ['vnTemplate']; +export function directive(vnTemplate) { + return { + restrict: 'E', + template: (_, $attrs) => + vnTemplate.getNormalized(template, $attrs, { + label: '', + rows: 3 + }), + link: function(scope, element, attrs) { + scope.$watch(attrs.model, () => { + let mdlField = element[0].firstChild.MaterialTextfield; + if (mdlField) + mdlField.updateClasses_(); + }); + componentHandler.upgradeElement(element[0].firstChild); + } + }; +} +ngModule.directive('vnTextarea', directive); diff --git a/client/core/src/textfield/style.scss b/client/core/src/components/textfield/style.scss similarity index 100% rename from client/core/src/textfield/style.scss rename to client/core/src/components/textfield/style.scss diff --git a/client/core/src/textfield/textfield.html b/client/core/src/components/textfield/textfield.html similarity index 87% rename from client/core/src/textfield/textfield.html rename to client/core/src/components/textfield/textfield.html index e709c835d..43599186b 100644 --- a/client/core/src/textfield/textfield.html +++ b/client/core/src/components/textfield/textfield.html @@ -11,8 +11,7 @@ ng-disabled="$ctrl.disabled" ng-readonly="$ctrl.readonly" ng-focus="$ctrl.hasFocus = true" - ng-blur="$ctrl.hasFocus = false" - /> + ng-blur="$ctrl.hasFocus = false"/>
- +
diff --git a/client/core/src/textfield/textfield.js b/client/core/src/components/textfield/textfield.js similarity index 63% rename from client/core/src/textfield/textfield.js rename to client/core/src/components/textfield/textfield.js index b9262bc0e..feb5b98a9 100644 --- a/client/core/src/textfield/textfield.js +++ b/client/core/src/components/textfield/textfield.js @@ -1,22 +1,14 @@ -import {module} from '../module'; -import Input from '../lib/input'; +import ngModule from '../../module'; +import Input from '../../lib/input'; import './style.scss'; export default class Textfield extends Input { - constructor($element, $scope, $attrs, $timeout, normalizer) { - super($element); - - normalizer.normalize($attrs); - - this.$scope = $scope; - this.$attrs = $attrs; - this.$element = $element; - this.$timeout = $timeout; - + constructor($element, $scope, $attrs, vnTemplate) { + super($element, $scope); + vnTemplate.normalizeInputAttrs($attrs); this._value = null; this.type = $attrs.type || 'text'; this.showActions = false; - this.input = $element[0].querySelector('input'); this.hasInfo = Boolean($attrs.info); this.info = $attrs.info || null; this.hasFocus = false; @@ -35,19 +27,18 @@ export default class Textfield extends Input { set tabIndex(value) { this.input.tabIndex = value; } - mdlUpdate() { - let mdlField = this.$element[0].firstChild.MaterialTextfield; - if (mdlField) - mdlField.updateClasses_(); - } clear() { this.value = null; this.input.focus(); } + mdlUpdate() { + let mdlElement = this.element.firstChild.MaterialTextfield; + if (mdlElement) mdlElement.updateClasses_(); + } } -Textfield.$inject = ['$element', '$scope', '$attrs', '$timeout', 'vnInputAttrsNormalizer']; +Textfield.$inject = ['$element', '$scope', '$attrs', 'vnTemplate']; -module.component('vnTextfield', { +ngModule.component('vnTextfield', { template: require('./textfield.html'), controller: Textfield, bindings: { diff --git a/client/core/src/textfield/textfield.spec.js b/client/core/src/components/textfield/textfield.spec.js similarity index 100% rename from client/core/src/textfield/textfield.spec.js rename to client/core/src/components/textfield/textfield.spec.js diff --git a/client/core/src/title/title.html b/client/core/src/components/title/title.html similarity index 100% rename from client/core/src/title/title.html rename to client/core/src/components/title/title.html diff --git a/client/core/src/components/title/title.js b/client/core/src/components/title/title.js new file mode 100644 index 000000000..15e0b7c84 --- /dev/null +++ b/client/core/src/components/title/title.js @@ -0,0 +1,6 @@ +import ngModule from '../../module'; + +ngModule.component('vnTitle', { + template: require('./title.html'), + transclude: true +}); diff --git a/client/core/src/tooltip/style.css b/client/core/src/components/tooltip/style.css similarity index 100% rename from client/core/src/tooltip/style.css rename to client/core/src/components/tooltip/style.css diff --git a/client/core/src/tooltip/tooltip.js b/client/core/src/components/tooltip/tooltip.js similarity index 98% rename from client/core/src/tooltip/tooltip.js rename to client/core/src/components/tooltip/tooltip.js index 75d2f1e17..101ce357a 100644 --- a/client/core/src/tooltip/tooltip.js +++ b/client/core/src/components/tooltip/tooltip.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import ngModule from '../../module'; import './style.css'; tooltip.$inject = ['$document', '$compile', '$interpolate', '$sce', '$templateCache', '$http', '$q']; @@ -122,4 +122,4 @@ function tooltip($document, $compile, $interpolate, $sce, $templateCache, $http, }; } -module.directive('vnTooltip', tooltip); +ngModule.directive('vnTooltip', tooltip); diff --git a/client/core/src/watcher/locale/es.yml b/client/core/src/components/watcher/locale/es.yml similarity index 100% rename from client/core/src/watcher/locale/es.yml rename to client/core/src/components/watcher/locale/es.yml diff --git a/client/core/src/watcher/watcher.html b/client/core/src/components/watcher/watcher.html similarity index 100% rename from client/core/src/watcher/watcher.html rename to client/core/src/components/watcher/watcher.html diff --git a/client/core/src/watcher/watcher.js b/client/core/src/components/watcher/watcher.js similarity index 95% rename from client/core/src/watcher/watcher.js rename to client/core/src/components/watcher/watcher.js index 18ce80117..12b8af599 100644 --- a/client/core/src/watcher/watcher.js +++ b/client/core/src/components/watcher/watcher.js @@ -1,9 +1,9 @@ -import {module} from '../module'; -import Component from '../lib/component'; -import getModifiedData from '../lib/modified'; -import copyObject from '../lib/copy'; -import isEqual from '../lib/equals'; -import isFullEmpty from '../lib/fullEmpty'; +import ngModule from '../../module'; +import Component from '../../lib/component'; +import getModifiedData from '../../lib/modified'; +import copyObject from '../../lib/copy'; +import isEqual from '../../lib/equals'; +import isFullEmpty from '../../lib/full-empty'; /** * Component that checks for changes on a specific model property and @@ -206,10 +206,9 @@ export default class Watcher extends Component { } } } - Watcher.$inject = ['$element', '$scope', '$state', '$transitions', '$http', 'vnApp', '$translate', '$attrs']; -module.component('vnWatcher', { +ngModule.component('vnWatcher', { template: require('./watcher.html'), bindings: { url: '@?', diff --git a/client/core/src/watcher/watcher.spec.js b/client/core/src/components/watcher/watcher.spec.js similarity index 99% rename from client/core/src/watcher/watcher.spec.js rename to client/core/src/components/watcher/watcher.spec.js index 231680f28..88305c819 100644 --- a/client/core/src/watcher/watcher.spec.js +++ b/client/core/src/components/watcher/watcher.spec.js @@ -1,5 +1,5 @@ import './watcher.js'; -import getModifiedData from '../lib/modified'; +import getModifiedData from '../../lib/modified'; describe('Component vnWatcher', () => { let $componentController; diff --git a/client/core/src/config.js b/client/core/src/config.js deleted file mode 100644 index 2687e2c1f..000000000 --- a/client/core/src/config.js +++ /dev/null @@ -1,33 +0,0 @@ -import {module} from './module'; - -config.$inject = ['$translateProvider', '$translatePartialLoaderProvider']; -export function config($translateProvider, $translatePartialLoaderProvider) { - $translatePartialLoaderProvider.addPart('core'); - - let conf = {urlTemplate: '/static/locale/{part}/{lang}.json'}; - - let fallbackLang = 'es'; - let langs = ['en', 'es']; - let langAliases = { - en_US: 'en', - en_UK: 'en', - es_ES: 'es', - es_AR: 'es' - }; - - $translateProvider - .useSanitizeValueStrategy('escape') - .useLoader('$translatePartialLoader', conf) - .registerAvailableLanguageKeys(langs, langAliases) - // FIXME: Circular dependency due to vnInterceptor - // .fallbackLanguage(fallbackLang) - .determinePreferredLanguage(() => { - let locale = $translateProvider.resolveClientLocale(); - if (langs.indexOf(locale) !== -1) - return locale; - if (langAliases[locale]) - return langAliases[locale]; - return fallbackLang; - }); -} -module.config(config); diff --git a/client/core/src/core.js b/client/core/src/core.js index bb9eb7f56..6bc5b8bdc 100644 --- a/client/core/src/core.js +++ b/client/core/src/core.js @@ -1,6 +1,8 @@ -export * from './config'; +import './styles/mdl-override.css'; +import './styles/mdi-override.css'; + export * from './module'; export * from './directives/index'; export * from './filters/index'; export * from './lib/index'; -export * from './components'; +export * from './components/index'; diff --git a/client/core/src/directives/acl.js b/client/core/src/directives/acl.js index f29142e1f..6daf5a333 100644 --- a/client/core/src/directives/acl.js +++ b/client/core/src/directives/acl.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import ngModule from '../module'; function vnAcl(aclService, $timeout) { function getMaterialType(className) { @@ -9,7 +9,7 @@ function vnAcl(aclService, $timeout) { } return type; } - function udateMaterial(input) { + function updateMaterial(input) { if (input && input.className) { let find = input.className.match(/mdl-[\w]+input/g); if (find && find.length && find[0]) { @@ -37,7 +37,7 @@ function vnAcl(aclService, $timeout) { if (input) { $timeout(() => { input.setAttribute("disabled", "true"); - udateMaterial(input); + updateMaterial(input); }); $element[0].querySelectorAll('i, vn-drop-down').forEach(element => { element.parentNode.removeChild(element); @@ -52,4 +52,4 @@ function vnAcl(aclService, $timeout) { } vnAcl.$inject = ['aclService', '$timeout']; -module.directive('vnAcl', vnAcl); +ngModule.directive('vnAcl', vnAcl); diff --git a/client/core/src/directives/dialog.js b/client/core/src/directives/dialog.js index 5ee10258e..7e51a8e9e 100644 --- a/client/core/src/directives/dialog.js +++ b/client/core/src/directives/dialog.js @@ -1,10 +1,12 @@ -import {module} from '../module'; -import Dialog from '../dialog/dialog'; +import ngModule from '../module'; +import Dialog from '../components/dialog/dialog'; import {kebabToCamel} from '../lib/string'; /** * Registers a click handler on the element that opens the dialog id * specified as value. + * + * @return {Object} The directive */ export function directive() { return { @@ -20,4 +22,4 @@ export function directive() { } }; } -module.directive('vnDialog', directive); +ngModule.directive('vnDialog', directive); diff --git a/client/core/src/directives/focus.js b/client/core/src/directives/focus.js index bf4d86122..26376a260 100644 --- a/client/core/src/directives/focus.js +++ b/client/core/src/directives/focus.js @@ -1,7 +1,7 @@ -import {module} from '../module'; +import ngModule from '../module'; /** - * Sets the focus and selects the text on the input. + * Sets the focus and selects the text on the input. * * @return {Object} The directive */ @@ -29,4 +29,4 @@ export function directive() { } }; } -module.directive('vnFocus', directive); +ngModule.directive('vnFocus', directive); diff --git a/client/core/src/directives/id.js b/client/core/src/directives/id.js index d3dbc7f05..75865751b 100644 --- a/client/core/src/directives/id.js +++ b/client/core/src/directives/id.js @@ -1,9 +1,11 @@ -import {module} from '../module'; +import ngModule from '../module'; import {kebabToCamel} from '../lib/string'; /** * Registers the element controller into its scope as a * property whose name is the directive value. + * + * @return {Object} The directive */ export function directive() { return { @@ -21,4 +23,4 @@ export function directive() { } }; } -module.directive('vnId', directive); +ngModule.directive('vnId', directive); diff --git a/client/core/src/directives/index.js b/client/core/src/directives/index.js index 67093faa8..da672b330 100644 --- a/client/core/src/directives/index.js +++ b/client/core/src/directives/index.js @@ -3,4 +3,4 @@ import './focus'; import './dialog'; import './validation'; import './acl'; -import './onErrorSrc'; +import './on-error-src'; diff --git a/client/core/src/directives/onErrorSrc.js b/client/core/src/directives/on-error-src.js similarity index 81% rename from client/core/src/directives/onErrorSrc.js rename to client/core/src/directives/on-error-src.js index fd3cf2b82..1462063d6 100644 --- a/client/core/src/directives/onErrorSrc.js +++ b/client/core/src/directives/on-error-src.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import ngModule from '../module'; function onErrorSrc() { return { @@ -13,5 +13,4 @@ function onErrorSrc() { } }; } - -module.directive('onErrorSrc', onErrorSrc); +ngModule.directive('onErrorSrc', onErrorSrc); diff --git a/client/core/src/directives/validation.js b/client/core/src/directives/validation.js index 09c4a9f8e..76a94da3b 100644 --- a/client/core/src/directives/validation.js +++ b/client/core/src/directives/validation.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import ngModule from '../module'; import {validateAll} from '../lib/validator'; import {firstUpper} from '../lib/string'; @@ -6,7 +6,7 @@ directive.$inject = ['$interpolate', '$compile', '$window']; export function directive(interpolate, compile, $window) { return { restrict: 'A', - require: ['ngModel', '?^^form'], + require: ['ngModel', '^^?form'], link: link }; @@ -32,14 +32,14 @@ export function directive(interpolate, compile, $window) { if (!validations || validations.length == 0) return; - let input = ctrl[0]; + let ngModel = ctrl[0]; let form = ctrl[1]; let errorSpan = angular.element(''); let errorMsg; let errorShown = false; - input.$options.$$options.allowInvalid = true; - input.$validators.entity = value => { + ngModel.$options.$$options.allowInvalid = true; + ngModel.$validators.entity = value => { try { validateAll(value, validations); return true; @@ -51,7 +51,7 @@ export function directive(interpolate, compile, $window) { }; scope.$watch(() => { - return (form.$submitted || input.$dirty) && input.$invalid; + return (form.$submitted || ngModel.$dirty) && ngModel.$invalid; }, value => { let parent = element.parent(); @@ -76,5 +76,5 @@ export function directive(interpolate, compile, $window) { } } } -module.directive('vnValidation', directive); +ngModule.directive('vnValidation', directive); diff --git a/client/core/src/filters/phone.js b/client/core/src/filters/phone.js index 3146e24c1..40701f9e2 100644 --- a/client/core/src/filters/phone.js +++ b/client/core/src/filters/phone.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import ngModule from '../module'; /** * Formats a phone number putting a space every three digits. @@ -17,4 +17,4 @@ export default function phone() { return out; }; } -module.filter('phone', phone); +ngModule.filter('phone', phone); diff --git a/client/core/src/filters/ucwords.js b/client/core/src/filters/ucwords.js index 08ca725eb..5939d343d 100644 --- a/client/core/src/filters/ucwords.js +++ b/client/core/src/filters/ucwords.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import ngModule from '../module'; /** * Uppercase the first character of each word in a string @@ -17,4 +17,4 @@ export default function ucwords() { return out.trim(); }; } -module.filter('ucwords', ucwords); +ngModule.filter('ucwords', ucwords); diff --git a/client/core/src/floatbutton/floatbutton.js b/client/core/src/floatbutton/floatbutton.js deleted file mode 100644 index 56cbbcb40..000000000 --- a/client/core/src/floatbutton/floatbutton.js +++ /dev/null @@ -1,19 +0,0 @@ -import {module as _module} from '../module'; -import * as resolveFactory from '../lib/resolveDefaultComponents'; -import * as util from '../lib/util'; - -const _NAME = 'floatButton'; -export const NAME = util.getName(_NAME); - -directive.$inject = [resolveFactory.NAME]; -export function directive(resolve) { - return { - restrict: 'E', - template: function(_, attr) { - return resolve.getTemplate(_NAME, attr); - } - }; -} - -_module.directive(NAME, directive); - diff --git a/client/core/src/floatbutton/floatbutton.mdl.js b/client/core/src/floatbutton/floatbutton.mdl.js deleted file mode 100644 index 68b585d24..000000000 --- a/client/core/src/floatbutton/floatbutton.mdl.js +++ /dev/null @@ -1,20 +0,0 @@ -import {module as _module} from '../module'; -import * as util from '../lib/util'; -import * as constant from '../lib/constants'; -import template from './floatbutton.mdl.html'; - -const _NAME = 'floatButton'; -const DEFAULT_CLASS = 'mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--colored'; - -export const NAME = util.getFactoryName(_NAME + constant.MATERIAL_DESIGN_FRAMEWORK); - -export function factory() { - return { - template: template, - default: { - className: DEFAULT_CLASS - } - }; -} - -_module.factory(NAME, factory); diff --git a/client/core/src/icon-button/icon-button.html b/client/core/src/icon-button/icon-button.html deleted file mode 100644 index 4bd12c620..000000000 --- a/client/core/src/icon-button/icon-button.html +++ /dev/null @@ -1,3 +0,0 @@ - \ No newline at end of file diff --git a/client/core/src/label/label.js b/client/core/src/label/label.js deleted file mode 100644 index 00966a9ea..000000000 --- a/client/core/src/label/label.js +++ /dev/null @@ -1,18 +0,0 @@ -import {module as _module} from '../module'; -import * as resolveFactory from '../lib/resolveDefaultComponents'; -import * as util from '../lib/util'; - -const _NAME = 'label'; -export const NAME = util.getName(_NAME); - -directive.$inject = [resolveFactory.NAME]; -export function directive(resolve) { - return { - restrict: 'E', - template: function(_, attr) { - return resolve.getTemplate(_NAME, attr); - } - }; -} - -_module.directive(NAME, directive); diff --git a/client/core/src/label/label.mdl.js b/client/core/src/label/label.mdl.js deleted file mode 100644 index 0f66320d7..000000000 --- a/client/core/src/label/label.mdl.js +++ /dev/null @@ -1,20 +0,0 @@ -import {module as _module} from '../module'; -import * as util from '../lib/util'; -import * as constant from '../lib/constants'; -import template from './label.mdl.html'; - -const _NAME = 'label'; -const DEFAULT_TEXT = 'label'; - -export const NAME = util.getFactoryName(_NAME + constant.MATERIAL_DESIGN_FRAMEWORK); - -export function factory() { - return { - template: template, - default: { - text: DEFAULT_TEXT - } - }; -} - -_module.factory(NAME, factory); diff --git a/client/core/src/lib/aclService.js b/client/core/src/lib/acl-service.js similarity index 88% rename from client/core/src/lib/aclService.js rename to client/core/src/lib/acl-service.js index 78e5d2365..ac2a11bc3 100644 --- a/client/core/src/lib/aclService.js +++ b/client/core/src/lib/acl-service.js @@ -1,7 +1,7 @@ -import {module} from '../module'; +import ngModule from '../module'; var acl = window.salix ? window.salix.acl : {}; -module.constant('aclConstant', acl); +ngModule.constant('aclConstant', acl); aclService.$inject = ['aclConstant']; function aclService(aclConstant) { @@ -32,4 +32,4 @@ function aclService(aclConstant) { }; } -module.service('aclService', aclService); +ngModule.service('aclService', aclService); diff --git a/client/core/src/lib/app.js b/client/core/src/lib/app.js index c3676de77..7cbcb3b13 100644 --- a/client/core/src/lib/app.js +++ b/client/core/src/lib/app.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import ngModule from '../module'; /** * The main application class. @@ -34,4 +34,4 @@ export default class App { } App.$inject = ['$rootScope']; -module.service('vnApp', App); +ngModule.service('vnApp', App); diff --git a/client/core/src/lib/component.js b/client/core/src/lib/component.js index 2d8d689cc..2184b72fd 100644 --- a/client/core/src/lib/component.js +++ b/client/core/src/lib/component.js @@ -18,10 +18,12 @@ export default class Component { * Contructor. * * @param {HTMLElement} $element The main component element + * @param {$rootScope.Scope} $scope The element scope */ - constructor($element) { + constructor($element, $scope) { + this.$ = $scope; + this.$element = $element; this.element = $element[0]; - this.element.$ctrl = this; } } -Component.$inject = ['$element']; +Component.$inject = ['$element', '$scope']; diff --git a/client/core/src/lib/constants.js b/client/core/src/lib/constants.js deleted file mode 100644 index ebfeec4b2..000000000 --- a/client/core/src/lib/constants.js +++ /dev/null @@ -1,10 +0,0 @@ - -// Proyect prefix name -export const PREFIX = 'vn'; - -// CSS frameworks -export const MATERIAL_DESIGN_FRAMEWORK = 'Mdl'; -export const BOOTSTRAP_FRAMEWORK = 'Bt'; - -// Module dependencies -export const EMPTY_DEPENDECIES = []; diff --git a/client/core/src/lib/copy.js b/client/core/src/lib/copy.js index f0948de33..2a9dde35c 100644 --- a/client/core/src/lib/copy.js +++ b/client/core/src/lib/copy.js @@ -1,7 +1,3 @@ -import {module} from '../module'; const copyObject = angular.copy; export default copyObject; - -export const NAME = 'copyObject'; -module.value(NAME, copyObject); diff --git a/client/core/src/lib/crud.js b/client/core/src/lib/crud.js index fe2c39af2..33c4c2091 100644 --- a/client/core/src/lib/crud.js +++ b/client/core/src/lib/crud.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import ngModule from '../module'; index.$inject = ['mgIndex']; function index(mgIndex) { @@ -6,7 +6,7 @@ function index(mgIndex) { init: 'index.filter={page: 1, size: 5}' }); } -module.factory('vnIndex', index); +ngModule.factory('vnIndex', index); nonAuto.$inject = ['mgIndex']; function nonAuto(mgIndex) { @@ -14,7 +14,7 @@ function nonAuto(mgIndex) { auto: false }); } -module.factory('vnIndexNonAuto', nonAuto); +ngModule.factory('vnIndexNonAuto', nonAuto); successFactoryCreate.$inject = ['mgSuccessFactoryCreate']; function successFactoryCreate(create) { @@ -22,7 +22,7 @@ function successFactoryCreate(create) { back: undefined }); } -module.factory('vnSuccessFactoryCreate', successFactoryCreate); +ngModule.factory('vnSuccessFactoryCreate', successFactoryCreate); put.$inject = ['mgPut']; function put(mgPut) { @@ -30,7 +30,7 @@ function put(mgPut) { success: 'vnSuccessFactoryCreate' }); } -module.factory('vnPut', put); +ngModule.factory('vnPut', put); put.$inject = ['mgPatch']; function patch(mgPatch) { @@ -38,7 +38,7 @@ function patch(mgPatch) { success: 'vnSuccessFactoryCreate' }); } -module.factory('vnPatch', patch); +ngModule.factory('vnPatch', patch); post.$inject = ['mgCreate']; function post(mgCreate) { @@ -47,4 +47,4 @@ function post(mgCreate) { success: 'vnSuccessFactoryCreate' }); } -module.factory('vnPost', post); +ngModule.factory('vnPost', post); diff --git a/client/core/src/lib/equals.js b/client/core/src/lib/equals.js index 061d3f7c3..5c8e6c651 100644 --- a/client/core/src/lib/equals.js +++ b/client/core/src/lib/equals.js @@ -1,8 +1,3 @@ -import {module} from '../module'; const isEqual = angular.equals; - export default isEqual; - -export const NAME = 'equalsObject'; -module.value(NAME, isEqual); diff --git a/client/core/src/lib/filterList.js b/client/core/src/lib/filter-list.js similarity index 96% rename from client/core/src/lib/filterList.js rename to client/core/src/lib/filter-list.js index 34789a41d..1c63414d7 100644 --- a/client/core/src/lib/filterList.js +++ b/client/core/src/lib/filter-list.js @@ -1,4 +1,6 @@ -// Generic object to list models +/** + * Generic class to list models. + */ export default class FilterList { constructor($scope, $timeout, $state) { this.$ = $scope; diff --git a/client/core/src/lib/full-empty.js b/client/core/src/lib/full-empty.js new file mode 100644 index 000000000..65a0e1e1d --- /dev/null +++ b/client/core/src/lib/full-empty.js @@ -0,0 +1,7 @@ + +function isFullEmpty(item) { + return (item === null || item === undefined) || + (typeof item === 'object' && !Object.keys(item).length); +} + +export default isFullEmpty; diff --git a/client/core/src/lib/fullEmpty.js b/client/core/src/lib/fullEmpty.js deleted file mode 100644 index 86c8e6bce..000000000 --- a/client/core/src/lib/fullEmpty.js +++ /dev/null @@ -1,9 +0,0 @@ -import {module} from '../module'; - -const isFullEmpty = item => { - return (item === null || item === undefined) || (typeof item === 'object' && !Object.keys(item).length); -}; - -export default isFullEmpty; -export const NAME = 'isFullEmpty'; -module.value(NAME, isFullEmpty); diff --git a/client/core/src/lib/getTemplate.js b/client/core/src/lib/getTemplate.js deleted file mode 100644 index 58e891c7d..000000000 --- a/client/core/src/lib/getTemplate.js +++ /dev/null @@ -1,7 +0,0 @@ -import {kebabToCamel} from './string'; - -getTemplate.$inject = ['$element', '$attrs', 'vnResolveDefaultComponent']; -export default function getTemplate($element, $attrs, resolve) { - let templateName = kebabToCamel($element[0].tagName.toLowerCase().substr(3)); - return resolve.getTemplate(templateName, $attrs); -} diff --git a/client/core/src/lib/index.js b/client/core/src/lib/index.js index 0c8d89c9c..9df4b6911 100644 --- a/client/core/src/lib/index.js +++ b/client/core/src/lib/index.js @@ -1,18 +1,14 @@ -import './moduleLoader'; +import './module-loader'; import './crud'; -import './template'; -import './getTemplate'; import './app'; import './interceptor'; -import './aclService'; -import './storageServices'; -import './filterList'; - -export * from './util'; -export {default as splitingRegister} from './splitingRegister'; -export {NAME as RESOLVEDEFAULTCOMPONENT, ResolveDefaultComponent} from './resolveDefaultComponents'; -export {NAME as INTERPOLATE, Interpolate} from './interpolate'; -export {NAME as COPY_OBJECT} from './copy'; -export {NAME as EQUALS_OBJECT} from './equals'; -export {NAME as GET_DATA_MODIFIED, factory as Modified} from './modified'; -export {NAME as VALID_KEY} from './keyCodes'; +import './acl-service'; +import './storage-services'; +import './filter-list'; +import './template'; +import './spliting-register'; +import './interpolate'; +import './copy'; +import './equals'; +import './modified'; +import './key-codes'; diff --git a/client/core/src/lib/input.js b/client/core/src/lib/input.js index 8db191c33..9e428e675 100644 --- a/client/core/src/lib/input.js +++ b/client/core/src/lib/input.js @@ -4,10 +4,26 @@ import Component from './component'; * Component that host an input. */ export default class Input extends Component { + constructor($element, $scope) { + super($element, $scope); + this.input = this.element.querySelector('input'); + } + set disabled(value) { + this.input.disabled = value == true; + this.mdlUpdate(); + } + get disabled() { + return this.input.disabled; + } select() { this.input.select(); } focus() { this.input.focus(); } + mdlUpdate() { + if (this.mdlElement) + this.mdlElement.updateClasses_(); + } } +Input.$inject = ['$element', '$scope']; diff --git a/client/core/src/lib/inputAttrsNormalizer.js b/client/core/src/lib/inputAttrsNormalizer.js deleted file mode 100644 index 355d268b9..000000000 --- a/client/core/src/lib/inputAttrsNormalizer.js +++ /dev/null @@ -1,34 +0,0 @@ -import {module} from '../module'; - -export const NAME = 'vnInputAttrsNormalizer'; -export class InputAttrsNormalizer { - normalize(attrs) { - if (attrs.field) { - let split = attrs.field.split('.'); - let len = split.length; - - if (len == 0) - throw new Error(`Attribute 'field' can not be empty`); - if (len > 3) - throw new Error(`Attribute 'field' must have this syntax: [ctrl].[entity].[field]`); - - let i = len - 1; - let field = split[i--]; - let entity = i >= 0 ? split[i--] : 'model'; - let ctrl = i >= 0 ? split[i--] : '$ctrl'; - - if (attrs.model === undefined) - attrs.model = `${ctrl}.${entity}.${field}`; - if (attrs.rule === undefined && len >= 2) - attrs.rule = `${entity}.${field}`; - if (attrs.label === undefined && len >= 2) - attrs.label = `${entity}.${field}`; - if (attrs.name === undefined) - attrs.name = field; - } - - if (attrs.focus !== undefined) - attrs.focus = 'vn-focus'; - } -} -module.service(NAME, InputAttrsNormalizer); diff --git a/client/core/src/lib/interceptor.js b/client/core/src/lib/interceptor.js index 6d9266018..d6a2b4b59 100644 --- a/client/core/src/lib/interceptor.js +++ b/client/core/src/lib/interceptor.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import ngModule from '../module'; interceptor.$inject = ['$q', '$window', 'vnApp', '$translate', '$cookies']; function interceptor($q, $window, vnApp, $translate, $cookies) { @@ -49,4 +49,4 @@ function interceptor($q, $window, vnApp, $translate, $cookies) { } }; } -module.factory('vnInterceptor', interceptor); +ngModule.factory('vnInterceptor', interceptor); diff --git a/client/core/src/lib/interpolate.js b/client/core/src/lib/interpolate.js index c14a2079b..6321ce813 100644 --- a/client/core/src/lib/interpolate.js +++ b/client/core/src/lib/interpolate.js @@ -1,8 +1,5 @@ -import {module} from '../module'; +import ngModule from '../module'; import {ng} from 'vendor'; -import * as util from './util'; - -export const NAME = util.getProviderName('interpolate'); function stringify(value) { if (value === null) { // null || undefined @@ -35,11 +32,11 @@ $interpolateMinErr.interr = function(text, err) { }; function $get($parse, $exceptionHandler, $sce) { - var startSymbolLength = this._startSymbol.length, - endSymbolLength = this._endSymbol.length, - escapedStartRegexp = new RegExp(this._startSymbol.replace(/./g, escape), 'g'), - escapedEndRegexp = new RegExp(this._endSymbol.replace(/./g, escape), 'g'), - self = this; + let startSymbolLength = this._startSymbol.length; + let endSymbolLength = this._endSymbol.length; + let escapedStartRegexp = new RegExp(this._startSymbol.replace(/./g, escape), 'g'); + let escapedEndRegexp = new RegExp(this._endSymbol.replace(/./g, escape), 'g'); + let self = this; function escape(ch) { return '\\\\\\' + ch; @@ -74,15 +71,15 @@ function $get($parse, $exceptionHandler, $sce) { } allOrNothing = Boolean(allOrNothing); - var startIndex, - endIndex, - index = 0, - expressions = [], - parseFns = [], - textLength = text.length, - exp, - concat = [], - expressionPositions = []; + let startIndex; + let endIndex; + let index = 0; + let expressions = []; + let parseFns = []; + let textLength = text.length; + let exp; + let concat = []; + let expressionPositions = []; while (index < textLength) { if (((startIndex = text.indexOf(self._startSymbol, index)) !== -1) && @@ -107,6 +104,12 @@ function $get($parse, $exceptionHandler, $sce) { $interpolateMinErr.throwNoconcat(text); } + var getValue = function(value) { + return trustedContext ? + $sce.getTrusted(trustedContext, value) : + $sce.valueOf(value); + }; + if (!mustHaveExpression || expressions.length) { var compute = function(values) { for (var i = 0, ii = expressions.length; i < ii; i++) { @@ -116,12 +119,6 @@ function $get($parse, $exceptionHandler, $sce) { return concat.join(''); }; - var getValue = function(value) { - return trustedContext ? - $sce.getTrusted(trustedContext, value) : - $sce.valueOf(value); - }; - return angular.extend(function interpolationFn(context) { var i = 0; var ii = expressions.length; @@ -189,4 +186,4 @@ export class Interpolate { Interpolate.prototype.$get = $get; var interpolate = new Interpolate(); -module.provider(NAME, () => interpolate); +ngModule.provider('vnInterpolate', () => interpolate); diff --git a/client/core/src/lib/keyCodes.js b/client/core/src/lib/key-codes.js similarity index 71% rename from client/core/src/lib/keyCodes.js rename to client/core/src/lib/key-codes.js index 9586868ec..8c84b6b4d 100644 --- a/client/core/src/lib/keyCodes.js +++ b/client/core/src/lib/key-codes.js @@ -1,6 +1,5 @@ -import {module} from '../module'; -const validKey = key => { +export default function validKey(key) { let keycode = key.keyCode || key; let valid = @@ -11,9 +10,4 @@ const validKey = key => { (keycode > 218 && keycode < 223); // [\]' (in order) return valid; -}; - -export default validKey; - -export const NAME = 'validKey'; -module.value(NAME, validKey); +} diff --git a/client/core/src/lib/modified.js b/client/core/src/lib/modified.js index f62bc91ae..ede7f29be 100644 --- a/client/core/src/lib/modified.js +++ b/client/core/src/lib/modified.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import ngModule from '../module'; import isEqual from './equals'; export default function getModifiedData(object, objectOld) { @@ -21,6 +21,3 @@ export default function getModifiedData(object, objectOld) { return newObject; } - -export const NAME = 'getDataModified'; -module.value(NAME, getModifiedData); diff --git a/client/core/src/lib/moduleLoader.js b/client/core/src/lib/module-loader.js similarity index 93% rename from client/core/src/lib/moduleLoader.js rename to client/core/src/lib/module-loader.js index 42723ff0a..57cca1753 100644 --- a/client/core/src/lib/moduleLoader.js +++ b/client/core/src/lib/module-loader.js @@ -1,5 +1,5 @@ -import {module} from '../module'; -import splitingRegister from './splitingRegister'; +import ngModule from '../module'; +import splitingRegister from './spliting-register'; factory.$inject = ['$http', '$window', '$ocLazyLoad', '$translatePartialLoader', '$translate']; export function factory($http, $window, $ocLazyLoad, $translatePartialLoader, $translate) { @@ -32,7 +32,6 @@ export function factory($http, $window, $ocLazyLoad, $translatePartialLoader, $t .then(() => { let promises = []; - // FIXME: https://github.com/angular-translate/angular-translate/pull/1674 $translatePartialLoader.addPart(moduleName); promises.push(new Promise(resolve => { $translate.refresh().then( @@ -94,4 +93,4 @@ export function factory($http, $window, $ocLazyLoad, $translatePartialLoader, $t return new ModuleLoader(); } -module.factory('vnModuleLoader', factory); +ngModule.factory('vnModuleLoader', factory); diff --git a/client/core/src/lib/resolveDefaultComponents.js b/client/core/src/lib/resolveDefaultComponents.js deleted file mode 100644 index 58be1f72a..000000000 --- a/client/core/src/lib/resolveDefaultComponents.js +++ /dev/null @@ -1,28 +0,0 @@ -import {module} from '../module'; -import * as util from './util'; - -export const NAME = 'vnComponentResolver'; - -export default class ComponentResolver { - constructor($injector, vnInterpolate) { - this.$injector = $injector; - this.vnInterpolate = vnInterpolate; - this.frameworkName = 'Mdl'; - } - getTemplate(name, attrs) { - let factoryName = util.getFactoryName(name + this.frameworkName); - let factory = this.$injector.has(factoryName) ? - this.$injector.get(factoryName) : undefined; - - if (!factory) - throw new Error(`ComponentResolver: Factory '${factoryName}' is not defined`); - - let defaultValues = factory.default; - let template = factory.template; - let scope = Object.assign({}, defaultValues || {}, attrs || {}); - return template && this.vnInterpolate(template)(scope); - } -} -ComponentResolver.$inject = ['$injector', 'vnInterpolate']; - -module.service('vnComponentResolver', ComponentResolver); diff --git a/client/core/src/lib/specs/aclService.spec.js b/client/core/src/lib/specs/acl-service.spec.js similarity index 100% rename from client/core/src/lib/specs/aclService.spec.js rename to client/core/src/lib/specs/acl-service.spec.js diff --git a/client/core/src/lib/splitingRegister.js b/client/core/src/lib/spliting-register.js similarity index 100% rename from client/core/src/lib/splitingRegister.js rename to client/core/src/lib/spliting-register.js diff --git a/client/core/src/lib/storageServices.js b/client/core/src/lib/storage-services.js similarity index 92% rename from client/core/src/lib/storageServices.js rename to client/core/src/lib/storage-services.js index ee64b6f0c..bb766215e 100644 --- a/client/core/src/lib/storageServices.js +++ b/client/core/src/lib/storage-services.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import ngModule from '../module'; class VnStorage { constructor() { @@ -62,5 +62,5 @@ class LocalStorage extends VnStorage { } } -module.service('sessionStorage', SessionStorage); -module.service('localStorage', LocalStorage); +ngModule.service('sessionStorage', SessionStorage); +ngModule.service('localStorage', LocalStorage); diff --git a/client/core/src/lib/template.js b/client/core/src/lib/template.js index 59edd21cb..b8aa1b30e 100644 --- a/client/core/src/lib/template.js +++ b/client/core/src/lib/template.js @@ -1,8 +1,46 @@ -import {kebabToCamel} from './string'; +import ngModule from '../module'; -template.$inject = ['$element', '$attrs', 'vnInputAttrsNormalizer', 'vnResolveDefaultComponent']; -export default function template($element, $attrs, normalizer, resolve) { - normalizer.normalize($attrs); - let templateName = kebabToCamel($element[0].tagName.toLowerCase().substr(3)); - return resolve.getTemplate(templateName, $attrs); +export default class Template { + constructor(vnInterpolate) { + this.vnInterpolate = vnInterpolate; + } + get(template, $attrs, defaults) { + let scope = Object.assign({}, defaults, $attrs); + return template && this.vnInterpolate(template)(scope); + } + getNormalized(template, $attrs, defaults) { + this.normalizeInputAttrs($attrs); + return this.get(template, $attrs, defaults); + } + normalizeInputAttrs($attrs) { + if ($attrs.field) { + let split = $attrs.field.split('.'); + let len = split.length; + + if (len == 0) + throw new Error(`Attribute 'field' can not be empty`); + if (len > 3) + throw new Error(`Attribute 'field' must have this syntax: [ctrl].[entity].[field]`); + + let i = len - 1; + let field = split[i--]; + let entity = i >= 0 ? split[i--] : 'model'; + let ctrl = i >= 0 ? split[i--] : '$ctrl'; + + if ($attrs.model === undefined) + $attrs.model = `${ctrl}.${entity}.${field}`; + if ($attrs.rule === undefined && len >= 2) + $attrs.rule = `${entity}.${field}`; + if ($attrs.label === undefined && len >= 2) + $attrs.label = `${entity}.${field}`; + if ($attrs.name === undefined) + $attrs.name = field; + } + + if ($attrs.focus !== undefined) + $attrs.focus = 'vn-focus'; + } } +Template.$inject = ['vnInterpolate']; + +ngModule.service('vnTemplate', Template); diff --git a/client/core/src/lib/util.js b/client/core/src/lib/util.js deleted file mode 100644 index 0b135e2ce..000000000 --- a/client/core/src/lib/util.js +++ /dev/null @@ -1,36 +0,0 @@ -import * as constant from './constants'; - -const FACTORY = 'Factory'; -const SERVICE = 'Service'; - -export function getName(name) { - return constant.PREFIX + toUpperCamelCase(name); -} - -export function toUpperCamelCase(stringToConvert) { - return stringToConvert.substr(0, 1).toUpperCase() + stringToConvert.substr(1); -} - -export function getFactoryName(name) { - return getName(name) + FACTORY; -} - -export function getServiceName(name) { - return getName(name) + SERVICE; -} - -export function getModuleName(name) { - return constant.PREFIX + name; -} - -export function getProviderNameFromConfig(name) { - return getName(name) + 'Provider'; -} - -export function getProviderName(name) { - return getName(name); -} - -export function getTemplateName(componentName, frameworkName) { - return componentName + '.' + frameworkName + '.html'; -} diff --git a/client/core/src/module.js b/client/core/src/module.js index 52e9d046a..81fb84f00 100644 --- a/client/core/src/module.js +++ b/client/core/src/module.js @@ -7,4 +7,37 @@ Object.keys(vendors).forEach(vendor => { deps.push(name); }); -export const module = vendors.ng.module('vnCore', deps); +const ngModule = vendors.ng.module('vnCore', deps); +export default ngModule; + +config.$inject = ['$translateProvider', '$translatePartialLoaderProvider']; +export function config($translateProvider, $translatePartialLoaderProvider) { + $translatePartialLoaderProvider.addPart('core'); + + let conf = {urlTemplate: '/static/locale/{part}/{lang}.json'}; + + let fallbackLang = 'es'; + let langs = ['en', 'es']; + let langAliases = { + en_US: 'en', + en_UK: 'en', + es_ES: 'es', + es_AR: 'es' + }; + + $translateProvider + .useSanitizeValueStrategy('escape') + .useLoader('$translatePartialLoader', conf) + .registerAvailableLanguageKeys(langs, langAliases) + // FIXME: Circular dependency due to vnInterceptor + // .fallbackLanguage(fallbackLang) + .determinePreferredLanguage(() => { + let locale = $translateProvider.resolveClientLocale(); + if (langs.indexOf(locale) !== -1) + return locale; + if (langAliases[locale]) + return langAliases[locale]; + return fallbackLang; + }); +} +ngModule.config(config); diff --git a/client/core/src/radio/radio.js b/client/core/src/radio/radio.js deleted file mode 100644 index b23abdfd0..000000000 --- a/client/core/src/radio/radio.js +++ /dev/null @@ -1,18 +0,0 @@ -import {module as _module} from '../module'; -import * as resolveFactory from '../lib/resolveDefaultComponents'; -import * as util from '../lib/util'; - -const _NAME = 'radio'; -export const NAME = util.getName(_NAME); - -directive.$inject = [resolveFactory.NAME]; -export function directive(resolve) { - return { - restrict: 'E', - template: function(_, attrs) { - return resolve.getTemplate(_NAME, attrs); - } - }; -} - -_module.directive(NAME, directive); diff --git a/client/core/src/radio/radio.mdl.html b/client/core/src/radio/radio.mdl.html deleted file mode 100644 index ea61c7a90..000000000 --- a/client/core/src/radio/radio.mdl.html +++ /dev/null @@ -1,2 +0,0 @@ - -*[text]* diff --git a/client/core/src/radio/radio.mdl.js b/client/core/src/radio/radio.mdl.js deleted file mode 100644 index 135c32538..000000000 --- a/client/core/src/radio/radio.mdl.js +++ /dev/null @@ -1,21 +0,0 @@ -import {module as _module} from '../module'; -import * as util from '../lib/util'; -import * as constant from '../lib/constants'; -import template from './radio.mdl.html'; - -const _NAME = 'radio'; -const DEFAULT_CLASS = 'mdl-radio mdl-js-radio mdl-js-ripple-effect'; - -export const NAME = util.getFactoryName(_NAME + constant.MATERIAL_DESIGN_FRAMEWORK); - -export function factory() { - return { - template: template, - default: { - enabled: 'true', - className: DEFAULT_CLASS - } - }; -} - -_module.factory(NAME, factory); diff --git a/client/core/src/styles/fonts/Material-Design-Icons.woff2 b/client/core/src/styles/Material-Design-Icons.woff2 similarity index 100% rename from client/core/src/styles/fonts/Material-Design-Icons.woff2 rename to client/core/src/styles/Material-Design-Icons.woff2 diff --git a/client/core/src/styles/fonts/mdi-override.css b/client/core/src/styles/mdi-override.css similarity index 100% rename from client/core/src/styles/fonts/mdi-override.css rename to client/core/src/styles/mdi-override.css diff --git a/client/core/src/mdl-override.css b/client/core/src/styles/mdl-override.css similarity index 86% rename from client/core/src/mdl-override.css rename to client/core/src/styles/mdl-override.css index 3a1f391a2..d9c0fcf87 100644 --- a/client/core/src/mdl-override.css +++ b/client/core/src/styles/mdl-override.css @@ -1,7 +1,11 @@ /** * Rewrited CSS rules from Material Design Lite. - * TODO: don't use !important + * FIXME: don't use !important */ +body { + line-height: initial; + font-size: 12pt; +} .mdl-textfield { width: 100%; @@ -35,7 +39,7 @@ .mdl-dialog{ width: 400px; font-family: vn-font; - line-height:60px; + line-height: 60px; text-align: center; } diff --git a/client/core/src/submit/submit.js b/client/core/src/submit/submit.js deleted file mode 100644 index 3d0a8b185..000000000 --- a/client/core/src/submit/submit.js +++ /dev/null @@ -1,18 +0,0 @@ -import {module as _module} from '../module'; -import * as resolveFactory from '../lib/resolveDefaultComponents'; -import * as util from '../lib/util'; - -const _NAME = 'submit'; -export const NAME = util.getName(_NAME); - -directive.$inject = [resolveFactory.NAME]; -export function directive(resolve) { - return { - restrict: 'E', - template: function(_, attr) { - return resolve.getTemplate(_NAME, attr); - } - }; -} - -_module.directive(NAME, directive); diff --git a/client/core/src/submit/submit.mdl.html b/client/core/src/submit/submit.mdl.html deleted file mode 100644 index d6fc98b52..000000000 --- a/client/core/src/submit/submit.mdl.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/client/core/src/submit/submit.mdl.js b/client/core/src/submit/submit.mdl.js deleted file mode 100644 index e0e1dc074..000000000 --- a/client/core/src/submit/submit.mdl.js +++ /dev/null @@ -1,17 +0,0 @@ -import {module} from '../module'; -import template from './submit.mdl.html'; - -export const NAME = 'vnSubmitMdlFactory'; - -export function factory() { - return { - template: template, - default: { - label: 'Submit', - className: 'mdl-button mdl-js-button mdl-button--raised mdl-button--colored', - enabled: 'true' - } - }; -} - -module.factory(NAME, factory); diff --git a/client/core/src/subtitle/subtitle.js b/client/core/src/subtitle/subtitle.js deleted file mode 100644 index c98c25994..000000000 --- a/client/core/src/subtitle/subtitle.js +++ /dev/null @@ -1,6 +0,0 @@ -import {module} from '../module'; - -module.component('vnSubtitle', { - template: require('./subtitle.html'), - transclude: true -}); diff --git a/client/core/src/switch/switch.js b/client/core/src/switch/switch.js deleted file mode 100644 index 8c8186b32..000000000 --- a/client/core/src/switch/switch.js +++ /dev/null @@ -1,29 +0,0 @@ -import {module as _module} from '../module'; -import * as resolveFactory from '../lib/resolveDefaultComponents'; -import * as normalizerFactory from '../lib/inputAttrsNormalizer'; -import * as util from '../lib/util'; - -const _NAME = 'switch'; -export const NAME = util.getName(_NAME); - -directive.$inject = [resolveFactory.NAME, normalizerFactory.NAME]; -export function directive(resolve, normalizer) { - return { - restrict: 'E', - template: function(_, attrs) { - normalizer.normalize(attrs); - return resolve.getTemplate(_NAME, attrs); - }, - link: function(scope, element, attrs) { - scope.$watch(attrs.model, () => { - let mdlField = element[0].firstChild.MaterialSwitch; - if (mdlField) - mdlField.updateClasses_(); - }); - componentHandler.upgradeElement(element[0].firstChild); - } - }; -} - -_module.directive(NAME, directive); - diff --git a/client/core/src/switch/switch.mdl.js b/client/core/src/switch/switch.mdl.js deleted file mode 100644 index 34fda26ee..000000000 --- a/client/core/src/switch/switch.mdl.js +++ /dev/null @@ -1,21 +0,0 @@ -import {module as _module} from '../module'; -import * as util from '../lib/util'; -import * as constant from '../lib/constants'; -import template from './switch.mdl.html'; - -const _NAME = 'switch'; -const DEFAULT_CLASS = 'mdl-switch__input'; - -export const NAME = util.getFactoryName(_NAME + constant.MATERIAL_DESIGN_FRAMEWORK); - -export function factory() { - return { - template: template, - default: { - className: DEFAULT_CLASS, - label: "" - } - }; -} - -_module.factory(NAME, factory); diff --git a/client/core/src/textarea/textarea.js b/client/core/src/textarea/textarea.js deleted file mode 100644 index 192eb488b..000000000 --- a/client/core/src/textarea/textarea.js +++ /dev/null @@ -1,27 +0,0 @@ -import {module as _module} from '../module'; -import * as resolveFactory from '../lib/resolveDefaultComponents'; -import * as util from '../lib/util'; - -const _NAME = 'textarea'; -export const NAME = util.getName(_NAME); - -directive.$inject = [resolveFactory.NAME]; -export function directive(resolve) { - return { - restrict: 'E', - template: function(_, attr) { - return resolve.getTemplate(_NAME, attr); - }, - link: function(scope, element, attrs) { - scope.$watch(attrs.model, () => { - let mdlField = element[0].firstChild.MaterialTextfield; - if (mdlField) - mdlField.updateClasses_(); - }); - componentHandler.upgradeElement(element[0].firstChild); - } - }; -} - -_module.directive(NAME, directive); - diff --git a/client/core/src/textarea/textarea.mdl.html b/client/core/src/textarea/textarea.mdl.html deleted file mode 100644 index 1b156b18b..000000000 --- a/client/core/src/textarea/textarea.mdl.html +++ /dev/null @@ -1,4 +0,0 @@ -
- - -
\ No newline at end of file diff --git a/client/core/src/textarea/textarea.mdl.js b/client/core/src/textarea/textarea.mdl.js deleted file mode 100644 index be2a51561..000000000 --- a/client/core/src/textarea/textarea.mdl.js +++ /dev/null @@ -1,22 +0,0 @@ -import {module as _module} from '../module'; -import * as util from '../lib/util'; -import * as constant from '../lib/constants'; -import template from './textarea.mdl.html'; - -const _NAME = 'textarea'; -const DEFAULT_LABEL = 'textarea'; -const DEFAULT_ROWS = 3; - -export const NAME = util.getFactoryName(_NAME + constant.MATERIAL_DESIGN_FRAMEWORK); - -export function factory() { - return { - template: template, - default: { - label: DEFAULT_LABEL, - rows: DEFAULT_ROWS - } - }; -} - -_module.factory(NAME, factory); diff --git a/client/core/src/title/title.js b/client/core/src/title/title.js deleted file mode 100644 index 3420738e1..000000000 --- a/client/core/src/title/title.js +++ /dev/null @@ -1,6 +0,0 @@ -import {module} from '../module'; - -module.component('vnTitle', { - template: require('./title.html'), - transclude: true -}); diff --git a/client/item/src/filterItemList.js b/client/item/src/filter-item-list.js similarity index 81% rename from client/item/src/filterItemList.js rename to client/item/src/filter-item-list.js index 6c084944d..e170186bd 100644 --- a/client/item/src/filterItemList.js +++ b/client/item/src/filter-item-list.js @@ -1,4 +1,5 @@ -import FilterList from '../../core/src/lib/filterList'; +import FilterList from 'core/src/lib/filter-list'; + export default class FilterItemList extends FilterList { constructor($scope, $timeout, $state) { super($scope, $timeout, $state); diff --git a/client/item/src/history/item-history.js b/client/item/src/history/item-history.js index cf5d051b7..b89dca928 100644 --- a/client/item/src/history/item-history.js +++ b/client/item/src/history/item-history.js @@ -1,5 +1,5 @@ import ngModule from '../module'; -import FilterItemList from '../filterItemList'; +import FilterItemList from '../filter-item-list'; ngModule.component('vnItemHistory', { template: require('./item-history.html'), diff --git a/client/item/src/item.js b/client/item/src/item.js index b4a0b4d93..6ba7dd8cf 100644 --- a/client/item/src/item.js +++ b/client/item/src/item.js @@ -1,6 +1,6 @@ export * from './module'; -import './filterItemList'; +import './filter-item-list'; import './list/list'; import './filter-panel/filter-panel'; import './create/item-create'; diff --git a/client/salix/index.js b/client/salix/index.js index 86286a300..14e899cd0 100644 --- a/client/salix/index.js +++ b/client/salix/index.js @@ -1 +1 @@ -export * from './src/app'; +export * from './src/salix'; diff --git a/client/salix/src/app.js b/client/salix/src/app.js deleted file mode 100644 index 5695d02b5..000000000 --- a/client/salix/src/app.js +++ /dev/null @@ -1,7 +0,0 @@ -import './module'; -import './configroutes'; -import './config'; -import './run'; -import './components'; -import './styles/index'; -import './modulesFactory'; diff --git a/client/salix/src/components.js b/client/salix/src/components.js deleted file mode 100644 index cc2cd84f6..000000000 --- a/client/salix/src/components.js +++ /dev/null @@ -1,8 +0,0 @@ -export {NAME as APP, COMPONENT as APP_COMPONENT} from './components/app/app'; -export {NAME as VN_HOME, COMPONENT as VN_COMPONENT_HOME} from './components/home/home'; -export {NAME as VN_MAINMENU, COMPONENT as VN_MAINMENU_COMPONENT} from './components/main-menu/main-menu'; -export {NAME as ACTIONS, COMPONENT as ACTIONS_COMPONENT} from './components/left-menu/actions'; -export {NAME as LEFT_MENU, COMPONENT as LEFTMENU_COMPONENT} from './components/left-menu/left-menu'; -export {NAME as MENU_ITEM, COMPONENT as MENU_ITEM_COMPONENT} from './components/left-menu/menu-item'; -export {NAME as TOPBAR, COMPONENT as TOPBAR_COMPONENT} from './components/topbar/topbar'; -export {NAME as SEARCHBAR, COMPONENT as SEARCHBAR_COMPONENT} from './components/searchbar/searchbar'; diff --git a/client/salix/src/components/app/app.html b/client/salix/src/components/app/app.html index 0a447851f..adbc23575 100644 --- a/client/salix/src/components/app/app.html +++ b/client/salix/src/components/app/app.html @@ -1,7 +1,7 @@ - + diff --git a/client/salix/src/components/app/style.scss b/client/salix/src/components/app/style.scss index 61c1dee7b..fabe3dcca 100644 --- a/client/salix/src/components/app/style.scss +++ b/client/salix/src/components/app/style.scss @@ -9,12 +9,12 @@ vn-app { vn-topbar { .logo { float: left; - height: 30px; + height: 1.8em; padding: 1em; } vn-spinner { float: left; - padding: .9em; + padding: .4em; } } .main-view { diff --git a/client/salix/src/components/home/home.html b/client/salix/src/components/home/home.html index c79a78a77..df6699a79 100644 --- a/client/salix/src/components/home/home.html +++ b/client/salix/src/components/home/home.html @@ -3,18 +3,16 @@
- - + - - + +

-
\ No newline at end of file diff --git a/client/salix/src/components/index.js b/client/salix/src/components/index.js new file mode 100644 index 000000000..a2346bd91 --- /dev/null +++ b/client/salix/src/components/index.js @@ -0,0 +1,8 @@ +import './app/app'; +import './home/home'; +import './main-menu/main-menu'; +import './left-menu/actions'; +import './left-menu/left-menu'; +import './left-menu/menu-item'; +import './topbar/topbar'; +import './searchbar/searchbar'; diff --git a/client/salix/src/components/left-menu/actions.html b/client/salix/src/components/left-menu/actions.html index 3daf70551..9c10185fe 100644 --- a/client/salix/src/components/left-menu/actions.html +++ b/client/salix/src/components/left-menu/actions.html @@ -1,5 +1,5 @@
    - +
diff --git a/client/salix/src/components/left-menu/menu-item.html b/client/salix/src/components/left-menu/menu-item.html index 6930039f0..4f9541055 100644 --- a/client/salix/src/components/left-menu/menu-item.html +++ b/client/salix/src/components/left-menu/menu-item.html @@ -1,7 +1,7 @@
  • - + keyboard_arrow_right - {{$ctrl.item.icon}} - {{$ctrl.item.description}} + {{::$ctrl.item.icon}} + {{::$ctrl.item.description}}
  • \ No newline at end of file diff --git a/client/salix/src/components/main-menu/main-menu.html b/client/salix/src/components/main-menu/main-menu.html index 5d96d9b19..4bd1f950f 100644 --- a/client/salix/src/components/main-menu/main-menu.html +++ b/client/salix/src/components/main-menu/main-menu.html @@ -1,6 +1,21 @@
    - +
      +
    • + {{::lang}} +
    • +
    + +
      +
    • + + + +
    • +
    -
      -
    • - - - -
    • -
    diff --git a/client/salix/src/components/main-menu/main-menu.js b/client/salix/src/components/main-menu/main-menu.js index ce36593ce..0e02e6fb0 100644 --- a/client/salix/src/components/main-menu/main-menu.js +++ b/client/salix/src/components/main-menu/main-menu.js @@ -6,14 +6,13 @@ export default class MainMenu { this.$translate = $translate; this.$window = $window; this.modules = modulesFactory.getModules(); + this.langs = $translate.getAvailableLanguageKeys(); } onLogoutClick() { this.$window.location = '/logout'; } - onChangeLanguage() { - let lang = this.$translate.use() == 'en' ? 'es' : 'en'; + onChangeLangClick(lang) { this.$translate.use(lang); - console.log(`Locale changed: ${lang}`); } } MainMenu.$inject = ['$translate', '$window', 'modulesFactory']; diff --git a/client/salix/src/components/main-menu/style.scss b/client/salix/src/components/main-menu/style.scss index 5e1781446..bf50a606b 100644 --- a/client/salix/src/components/main-menu/style.scss +++ b/client/salix/src/components/main-menu/style.scss @@ -1,33 +1,32 @@ vn-main-menu { & > div > vn-icon { - font-size: 2.5em; + font-size: 2.2em; cursor: pointer; &:hover { color: #FF9300; } } - - li.mdl-menu__item{ + li.mdl-menu__item { background-color: #FF9300; margin-bottom: 8px; color: white; - img{ + img { max-width: 18px; vertical-align: middle; margin-top: -3px; } - i{ + i { float: left; padding-top: 13px; margin-right: 3px; } } - li.mdl-menu__item:hover{ + li.mdl-menu__item:hover { background-color: #FF9300; opacity: 0.7 !important; } - li.mdl-menu__item:last-child{ + li.mdl-menu__item:last-child { margin-bottom: 0; } } \ No newline at end of file diff --git a/client/salix/src/components/searchbar/searchbar.js b/client/salix/src/components/searchbar/searchbar.js index 06d572f33..f785b6aa7 100644 --- a/client/salix/src/components/searchbar/searchbar.js +++ b/client/salix/src/components/searchbar/searchbar.js @@ -16,7 +16,9 @@ export default class Controller { size: 20 }; } - // string search to json filter + /** + * String search to JSON filter + */ getFiltersFromSearch() { let toFind = this.stringSearch; let find; @@ -34,7 +36,11 @@ export default class Controller { } } } - // json filter to string search + /** + * JSON filter to string search + * + * @param {Object} filter The filter + */ createFilterSearch(filter) { let search = []; let keys = Object.keys(filter); @@ -83,7 +89,6 @@ export default class Controller { this.onSubmit(); }); } - onSubmit() { if (this.stringSearch) { this.getFiltersFromSearch(); diff --git a/client/salix/src/components/topbar/style.css b/client/salix/src/components/topbar/style.scss similarity index 77% rename from client/salix/src/components/topbar/style.css rename to client/salix/src/components/topbar/style.scss index b09b3fa2b..360018e01 100644 --- a/client/salix/src/components/topbar/style.css +++ b/client/salix/src/components/topbar/style.scss @@ -2,5 +2,5 @@ header { display: flex; flex-direction: row; flex: 1; - color: #ffffff; + color: #fff; } diff --git a/client/salix/src/components/topbar/topbar.js b/client/salix/src/components/topbar/topbar.js index 9e8a690c3..583354ad1 100644 --- a/client/salix/src/components/topbar/topbar.js +++ b/client/salix/src/components/topbar/topbar.js @@ -1,5 +1,5 @@ import ngModule from '../../module'; -import './style.css'; +import './style.scss'; ngModule.component('vnTopbar', { template: require('./topbar.html'), diff --git a/client/salix/src/configroutes.js b/client/salix/src/config-routes.js similarity index 97% rename from client/salix/src/configroutes.js rename to client/salix/src/config-routes.js index 357bb4880..4f3652ced 100644 --- a/client/salix/src/configroutes.js +++ b/client/salix/src/config-routes.js @@ -1,7 +1,7 @@ import ngModule from './module'; import deps from 'client/modules.yml'; import modules from 'client/spliting'; -import {splitingRegister} from 'core'; +import splitingRegister from 'core/src/lib/spliting-register'; function loader(moduleName, validations) { load.$inject = ['vnModuleLoader']; diff --git a/client/salix/src/config.js b/client/salix/src/config.js deleted file mode 100644 index 2d867074a..000000000 --- a/client/salix/src/config.js +++ /dev/null @@ -1,17 +0,0 @@ -import ngModule from './module'; - -export const appName = 'salix'; - -config.$inject = ['$translatePartialLoaderProvider', '$httpProvider']; -export function config($translatePartialLoaderProvider, $httpProvider) { - $translatePartialLoaderProvider.addPart(appName); - $httpProvider.interceptors.push('vnInterceptor'); -} -ngModule.config(config); - -run.$inject = ['$window', '$rootScope', 'vnApp']; -export function run($window, $rootScope, vnApp) { - $window.validations = {}; - vnApp.name = appName; -} -ngModule.run(run); diff --git a/client/salix/src/module.js b/client/salix/src/module.js index d0c4657a9..c0c539f3b 100644 --- a/client/salix/src/module.js +++ b/client/salix/src/module.js @@ -1,5 +1,33 @@ import {ng} from 'vendor'; import 'core'; +export const appName = 'salix'; + const ngModule = ng.module('salix', ['vnCore']); export default ngModule; + +config.$inject = ['$translatePartialLoaderProvider', '$httpProvider', '$qProvider']; +export function config($translatePartialLoaderProvider, $httpProvider, $qProvider) { + $translatePartialLoaderProvider.addPart(appName); + $httpProvider.interceptors.push('vnInterceptor'); + + // TODO: Handle or remove unhandled rejections + // $qProvider.errorOnUnhandledRejections(false); +} +ngModule.config(config); + +const HOOK_ABORTED_TRANSITION = 3; + +run.$inject = ['$window', '$rootScope', 'vnApp', '$state']; +export function run($window, $rootScope, vnApp, $state) { + $window.validations = {}; + vnApp.name = appName; + + $rootScope.$on('$viewContentLoaded', () => {}); + window.myAppErrorLog = []; + $state.defaultErrorHandler(function(error) { + if (error.type === HOOK_ABORTED_TRANSITION) + window.myAppErrorLog.push(error); + }); +} +ngModule.run(run); diff --git a/client/salix/src/modulesFactory.js b/client/salix/src/modules-factory.js similarity index 100% rename from client/salix/src/modulesFactory.js rename to client/salix/src/modules-factory.js diff --git a/client/salix/src/run.js b/client/salix/src/run.js deleted file mode 100644 index 84625e0d7..000000000 --- a/client/salix/src/run.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from './module'; - -const HOOK_ABORTED_TRANSITION = 3; - -run.$inject = ['$rootScope', '$state']; -export function run($rootScope, $state) { - $rootScope.$on('$viewContentLoaded', () => {}); - window.myAppErrorLog = []; - $state.defaultErrorHandler(function(error) { - if (error.type === HOOK_ABORTED_TRANSITION) - window.myAppErrorLog.push(error); - }); -} -ngModule.run(run); diff --git a/client/salix/src/salix.js b/client/salix/src/salix.js new file mode 100644 index 000000000..88ff6e001 --- /dev/null +++ b/client/salix/src/salix.js @@ -0,0 +1,5 @@ +import './module'; +import './config-routes'; +import './components/index'; +import './styles/index'; +import './modules-factory'; diff --git a/client/salix/src/styles/display.css b/client/salix/src/styles/display.scss similarity index 100% rename from client/salix/src/styles/display.css rename to client/salix/src/styles/display.scss diff --git a/client/salix/src/styles/font-family.css b/client/salix/src/styles/font-family.scss similarity index 100% rename from client/salix/src/styles/font-family.css rename to client/salix/src/styles/font-family.scss diff --git a/client/salix/src/styles/index.js b/client/salix/src/styles/index.js index e7dfd0622..20bd0d128 100644 --- a/client/salix/src/styles/index.js +++ b/client/salix/src/styles/index.js @@ -1,6 +1,6 @@ -import './title.css'; -import './layout.css'; -import './display.css'; +import './title.scss'; +import './layout.scss'; +import './display.scss'; import './margin.scss'; import './padding.scss'; import './background.scss'; diff --git a/client/salix/src/styles/layout.css b/client/salix/src/styles/layout.scss similarity index 100% rename from client/salix/src/styles/layout.css rename to client/salix/src/styles/layout.scss diff --git a/client/salix/src/styles/misc.scss b/client/salix/src/styles/misc.scss index 5138567a0..0b466d539 100644 --- a/client/salix/src/styles/misc.scss +++ b/client/salix/src/styles/misc.scss @@ -107,8 +107,8 @@ vn-main-block { margin: 0 auto; .left-block { - max-width: 20em; - min-width: 18em; + width: 16em; + min-width: 16em; padding-left: 1em; padding-bottom: 1em; } diff --git a/client/salix/src/styles/title.css b/client/salix/src/styles/title.scss similarity index 77% rename from client/salix/src/styles/title.css rename to client/salix/src/styles/title.scss index 1fe3e45ca..c32735686 100644 --- a/client/salix/src/styles/title.css +++ b/client/salix/src/styles/title.scss @@ -20,6 +20,7 @@ h6 { h1, h2, h3, h4, h5, h6 { padding: 0; - margin: .4em 0; + margin-top: 0; + margin-bottom: .2em; font-family: vn-font-bold; } \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 84d45e835..b69e22734 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -87,8 +87,8 @@ gulp.task('install', () => { // Deployment -gulp.task('build', ['clean'], () => { - return gulp.start('routes', 'locales', 'webpack', 'docker-compose', 'nginx-conf'); +gulp.task('build', ['clean'], async () => { + await runSequenceP(['routes', 'locales', 'webpack', 'docker-compose', 'nginx-conf']); }); gulp.task('docker-compose', async () => { @@ -161,7 +161,7 @@ gulp.task('nginx-stop', async () => { } catch (e) {} }); -gulp.task('nginx-conf', async () => { +gulp.task('nginx-conf', ['nginx-stop'], async () => { const mustache = require('mustache'); if (!await fs.exists(nginxTemp))