From 95caaf052ad927e5b14cce0965346e5708f6fcc7 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 17 Jan 2017 11:10:12 +0100 Subject: [PATCH] Dialogo directiva y provider --- @salix/app/src/components/app/app.js | 6 +- @salix/core/src/core.js | 1 + @salix/core/src/dialog/dialog.js | 72 +++++++++++++++++++ @salix/core/src/dialog/style.css | 22 ++++++ @salix/core/src/popover/popover.js | 6 +- .../subtitle/{template.html => index.html} | 0 @salix/core/src/subtitle/subtitle.js | 2 +- .../src/title/{template.html => index.html} | 0 @salix/core/src/title/title.js | 2 +- .../src/client/change-password/index.html | 9 +++ .../crud/src/client/change-password/index.js | 12 ++++ @salix/crud/src/client/client.js | 5 ++ @salix/crud/src/client/web-access/index.html | 13 ++-- dev.cmd | 5 +- dev.sh | 4 +- services/client/server/server.js | 1 - 16 files changed, 139 insertions(+), 21 deletions(-) create mode 100644 @salix/core/src/dialog/dialog.js create mode 100644 @salix/core/src/dialog/style.css rename @salix/core/src/subtitle/{template.html => index.html} (100%) rename @salix/core/src/title/{template.html => index.html} (100%) create mode 100644 @salix/crud/src/client/change-password/index.html create mode 100644 @salix/crud/src/client/change-password/index.js diff --git a/@salix/app/src/components/app/app.js b/@salix/app/src/components/app/app.js index fe2fd93bb2..d6d30a5637 100644 --- a/@salix/app/src/components/app/app.js +++ b/@salix/app/src/components/app/app.js @@ -24,9 +24,9 @@ function vnAppInterceptor($q, $rootScope, $document) { }, response: function(response) { switch (response.config.method) { - case 'PUT': - case 'POST': - showMessage('Data saved!'); + case 'PUT': + case 'POST': + showMessage('Data saved!'); } $rootScope.loading = false; return response; diff --git a/@salix/core/src/core.js b/@salix/core/src/core.js index 5c2e9a2da5..1dc3ed95c0 100644 --- a/@salix/core/src/core.js +++ b/@salix/core/src/core.js @@ -50,5 +50,6 @@ export {directive as Icon} from './icon/icon'; export {factory as IconMdl} from './icon/icon.mdl'; export {directive as Popover} from './popover/popover'; +export {directive as Dialog} from './dialog/dialog'; export {COMPONENT as Title} from './title/title'; export {COMPONENT as Subtitle} from './subtitle/subtitle'; diff --git a/@salix/core/src/dialog/dialog.js b/@salix/core/src/dialog/dialog.js new file mode 100644 index 0000000000..d7f7d14b25 --- /dev/null +++ b/@salix/core/src/dialog/dialog.js @@ -0,0 +1,72 @@ +import {module} from '../module'; +import * as resolveFactory from '../resolveDefaultComponents'; +require('./style.css'); + +directive.$inject = ['$compile', '$document', 'vnDialog']; +export function directive($compile, $document, dialog) { + return { + restrict: 'A', + link: function($scope, $element, $attrs, $ctrl) { + $element.on('click', function(event) { + let child = $document[0].createElement($attrs.vnDialog); + $compile(child)($scope); + dialog.show(child); + event.preventDefault(); + }); + } + } +} +module.directive('vnDialog', directive); + +provider.$inject = ['$document']; +function provider($document) { + let lastEvent; + let popup; + let background; + let self = { + onDialogMouseDown: function(event) { + lastEvent = event; + }, + onBackgroundMouseDown: function(event) { + if (event != lastEvent) + self.hide(); + }, + hide: function() { + $document[0].body.removeChild (background); + background = null; + popup = null; + }, + show: function(child) { + background = $document[0].createElement('div'); + background.className = 'vn-background'; + background.addEventListener('mousedown', this.onBackgroundMouseDown); + + popup = $document[0].createElement('div'); + popup.className = 'vn-dialog'; + popup.addEventListener('mousedown', this.onDialogMouseDown); + popup.appendChild (child); + background.appendChild (popup); + + let style = popup.style; + let screenMargin = 20; + + let width = popup.offsetWidth; + let height = popup.offsetHeight; + let innerWidth = window.innerWidth; + let innerHeight = window.innerHeight; + + if(width + screenMargin > innerWidth) { + width = innerWidth - dblMargin; + style.width = width +'px'; + } + if(height + screenMargin > innerHeight) { + height = innerHeight - dblMargin; + style.height = height +'px'; + } + + $document[0].body.appendChild (background); + } + }; + return self; +} +module.provider('vnDialog', function() {this.$get = provider;}); diff --git a/@salix/core/src/dialog/style.css b/@salix/core/src/dialog/style.css new file mode 100644 index 0000000000..bd60f7e640 --- /dev/null +++ b/@salix/core/src/dialog/style.css @@ -0,0 +1,22 @@ +.vn-dialog { + position: relative; + box-shadow: 0 0 .4em rgba(1,1,1,.4); + background-color: white; + border-radius: .2em; + overflow: auto; + top: 50%; + left: 50%; + + width: 400px; + margin-top: -150px; + margin-left: -200px; +} +.vn-background { + z-index: 100; + position: fixed; + left: 0; + top: 0; + height: 100%; + width: 100%; + background-color: rgba(1,1,1,.4); +} \ No newline at end of file diff --git a/@salix/core/src/popover/popover.js b/@salix/core/src/popover/popover.js index 0779a04c72..9412ff7be5 100644 --- a/@salix/core/src/popover/popover.js +++ b/@salix/core/src/popover/popover.js @@ -20,8 +20,8 @@ export function directive($compile, $document, popover) { } module.directive(NAME, directive); -$get.$inject = ['$document']; -function $get($document) { +provider.$inject = ['$document']; +function provider($document) { var lastEvent; var popover; var self = { @@ -90,4 +90,4 @@ function $get($document) { }; return self; } -module.provider('vnPopover', function() {this.$get = $get;}); +module.provider('vnPopover', function() {this.$get = provider;}); diff --git a/@salix/core/src/subtitle/template.html b/@salix/core/src/subtitle/index.html similarity index 100% rename from @salix/core/src/subtitle/template.html rename to @salix/core/src/subtitle/index.html diff --git a/@salix/core/src/subtitle/subtitle.js b/@salix/core/src/subtitle/subtitle.js index 7c0cb7c157..5c87ccf3ce 100644 --- a/@salix/core/src/subtitle/subtitle.js +++ b/@salix/core/src/subtitle/subtitle.js @@ -2,7 +2,7 @@ import {module} from '../module'; export const NAME = 'vnSubtitle'; export const COMPONENT = { - template: require('./template.html'), + template: require('./index.html'), transclude: true }; module.component(NAME, COMPONENT); diff --git a/@salix/core/src/title/template.html b/@salix/core/src/title/index.html similarity index 100% rename from @salix/core/src/title/template.html rename to @salix/core/src/title/index.html diff --git a/@salix/core/src/title/title.js b/@salix/core/src/title/title.js index f2a9a2372e..0a7362c986 100644 --- a/@salix/core/src/title/title.js +++ b/@salix/core/src/title/title.js @@ -2,7 +2,7 @@ import {module} from '../module'; export const NAME = 'vnTitle'; export const COMPONENT = { - template: require('./template.html'), + template: require('./index.html'), transclude: true }; module.component(NAME, COMPONENT); diff --git a/@salix/crud/src/client/change-password/index.html b/@salix/crud/src/client/change-password/index.html new file mode 100644 index 0000000000..f9ab9a090f --- /dev/null +++ b/@salix/crud/src/client/change-password/index.html @@ -0,0 +1,9 @@ +
+ + + + + + + +
diff --git a/@salix/crud/src/client/change-password/index.js b/@salix/crud/src/client/change-password/index.js new file mode 100644 index 0000000000..b4ac1f3b22 --- /dev/null +++ b/@salix/crud/src/client/change-password/index.js @@ -0,0 +1,12 @@ +export default { + template: require('./index.html'), + bindings: { + client: '<' + }, + controller: controller +}; + +controller.$inject = ['$element']; +function controller($element) { + this.submit = function () {}; +} diff --git a/@salix/crud/src/client/client.js b/@salix/crud/src/client/client.js index 544682006f..6fcc26a0b9 100644 --- a/@salix/crud/src/client/client.js +++ b/@salix/crud/src/client/client.js @@ -26,3 +26,8 @@ export {NAME as CLIENT_ADDRESSES_DATA_EDIT_INDEX, COMPONENT as CLIENT_ADDRESSES_DATA_EDIT_INDEX_COMPONENT} from './addresses-data-edit/index'; export {NAME as CLIENT_CONFIRM_INDEX, COMPONENT as CLIENT_CONFIRM_INDEX_COMPONENT} from './confirm/index'; + +import {module} from '../module'; + +import {default as changePassword} from './change-password/index'; +module.component('vnClientChangePassword', changePassword); \ No newline at end of file diff --git a/@salix/crud/src/client/web-access/index.html b/@salix/crud/src/client/web-access/index.html index 7e8e97433b..7fc36037d4 100644 --- a/@salix/crud/src/client/web-access/index.html +++ b/@salix/crud/src/client/web-access/index.html @@ -1,13 +1,14 @@
- Acceso Web - - + Web access + + - - - + + + +
diff --git a/dev.cmd b/dev.cmd index 7ad8db07b4..c39e33db8a 100644 --- a/dev.cmd +++ b/dev.cmd @@ -15,10 +15,7 @@ goto caseUsage if not exist "%nginxPrefix%\temp" (mkdir "%nginxPrefix%\temp") start /I nginx -c "%nginxConf%" -p "%nginxPrefix%" call forever start forever.json - call forever list - - cd @salix - gulp + gulp --gulpfile @salix\gulpfile.js goto caseExit :caseStop diff --git a/dev.sh b/dev.sh index 87123d9fe8..7252b2a5b1 100755 --- a/dev.sh +++ b/dev.sh @@ -12,9 +12,9 @@ case "$1" in start|"") $0 stop echo "################################ Starting services" - forever start forever.json "$nginxBin" -c "$nginxConf" -p "$nginxPrefix" - cd @salix && gulp + forever start forever.json + gulp --gulpfile @salix/gulpfile.js ;; stop) echo "################################ Stoping services" diff --git a/services/client/server/server.js b/services/client/server/server.js index 3d28538cc3..ef738abce2 100644 --- a/services/client/server/server.js +++ b/services/client/server/server.js @@ -27,4 +27,3 @@ boot(app, __dirname, function(err) { if (require.main === module) app.start(); }); -