From 275a9d022cfb9e38a47bd2ede64066bbe5d99369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Maur=C3=ADcio?= Date: Mon, 28 Apr 2014 16:07:20 +0000 Subject: [PATCH] git-svn-id: https://svn.coded.pt/svn/SIPRP@1869 bb69d46d-e84e-40c8-a05a-06db0d633741 --- .../static/html/app/Form1/Form1Controller.js | 48 ++++++++++---- .../static/html/app/Form1/Form1View.html | 63 +++++++----------- .../static/html/app/Main/MainController.js | 30 +++++++-- .../html/app/SearchForm/SearchController.js | 10 +-- .../html/app/SearchForm/SearchView.html | 66 +++++++++++-------- .../static/html/app/directives/customCombo.js | 57 +++++++++++----- .../static/html/app/directives/datatable.js | 6 +- .../static/html/app/directives/datepicker.js | 43 ++++++++++-- .../static/html/app/services/DataService.js | 2 +- .../static/html/app/services/Globals.js | 5 +- .../static/html/app/services/Message.js | 17 ++++- .../static/html/app/services/Settings.js | 8 +-- .../static/html/app/services/StaticData.js | 30 ++++++++- .../WebContent/static/html/css/theme.css | 22 ++++++- .../WebContent/static/html/index.html | 7 +- .../static/html/js/select2/select2.css | 10 +-- .../WebContent/static/html/views-all.html | 2 +- 17 files changed, 293 insertions(+), 133 deletions(-) diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form1/Form1Controller.js b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form1/Form1Controller.js index e0ff83b2..d2cee1ae 100644 --- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form1/Form1Controller.js +++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form1/Form1Controller.js @@ -4,7 +4,6 @@ $scope.calculatedAge = 0; - //TODO: review store name!!! $scope.storeFichasClinicas = new globals.dataService.store({ model: null, actions: { @@ -14,14 +13,8 @@ } }); - //$scope.$watch('editing.antecentesOcupacionaisActividadesAnteriores', function(newVal, oldVal){ - - //}); - $scope.add = function(selected){ - //$("body, html").animate({scrollTop : 0}, 500); - $scope.editForm.$reset(); $scope.editing = angular.copy(selected); @@ -30,7 +23,6 @@ $scope.editing.antecentesOcupacionaisAcidentesTrabalho = []; $scope.editing.antecentesOcupacionaisDoencasProfissionais = []; $scope.editing.antecentesOcupacionaisActividadesAnteriores = []; - }; $scope.edit = function(selected){ @@ -99,10 +91,13 @@ { $scope.storeFichasClinicas.upsert($scope.selected, $scope.editing, function(response, selected, editing, isNewRecord){ - if(isNewRecord) - { - //$scope.isNewRecord = isNewRecord; - } + //TODO: id's de cada ficha - injectar no modelo em edição + + + //if(isNewRecord) + //{ + // //$scope.isNewRecord = isNewRecord; + //} //$scope.editing.ficha.id = editing.ficha.id; @@ -129,8 +124,35 @@ $scope.cancel = function(){ - $scope.$parent.loadModule({Controller: 'Search'}, function(className, scope, isNewModule){ + globals.message.custom({ + title: null, + message: 'Pretende anular as alterações à ficha ou gravar para edição posterior?', + buttons: { + cancelar: { + label: 'Cancelar', + className: 'btn-default', + callback: function() { + //cancelar diálogo + } + }, + anular: { + label: 'Anular', + className: 'btn-danger', + callback: function() { + + $scope.$parent.loadModule({Controller: 'Search'}, function(className, scope, isNewModule){ + }); + } + }, + gravar: { + label: 'Gravar', + className: 'btn-success', + callback: function() { + $scope.save(); + } + } + } }); }; diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form1/Form1View.html b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form1/Form1View.html index 9fe2f2ca..15d486aa 100644 --- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form1/Form1View.html +++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form1/Form1View.html @@ -30,14 +30,14 @@
- +
- +
@@ -46,7 +46,7 @@
- +
@@ -54,7 +54,7 @@
- +
@@ -74,7 +74,7 @@
- +
@@ -84,11 +84,11 @@
@@ -101,7 +101,7 @@
- +
@@ -236,7 +236,6 @@

2 - Actividade

-
1.2 - Utente
@@ -246,7 +245,7 @@
- +
@@ -254,7 +253,7 @@
- +
@@ -265,7 +264,7 @@
- +
@@ -771,7 +770,7 @@ - + @@ -829,13 +828,13 @@ - + - + +
+ + +
diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Main/MainController.js b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Main/MainController.js index 865e4a3b..eb2102ef 100644 --- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Main/MainController.js +++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Main/MainController.js @@ -80,15 +80,16 @@ }; $rootScope.$on('onloginsuccessfull', function(event, args){ - + //set user session $rootScope.UserSession = { - userName: args.response.data + userName: args.response.data, + tiposFichas: globals.staticData.tiposFichas//TODO: this one needs to come from database }; // go to the default module and/or landing page $scope.loadModule({Controller: 'Search'}, function(className, scope, isNewModule){ - + }); }); @@ -394,16 +395,15 @@ if(result) { - $scope.storeUserSession.broadcastEvents = false; + $rootScope.$broadcast('loadingStatusActive'); $scope.storeUserSession.destroy(null, function(response){ - $scope.storeUserSession.broadcastEvents = true; + $rootScope.$broadcast('loadingStatusInactive'); if(response.success) { - //TODO: cleanup the whole application ??? - $rootScope.UserSession = null; + $scope.clearSession(); $scope.loadModule({Controller: 'Login'}, function(className, scope, isNewModule){ @@ -419,6 +419,22 @@ }); }; + // cleanup all session objects + $scope.clearSession = function(){ + + $rootScope.UserSession = null; + + $scope.currentModuleName = null; + + $scope.loadedModules = []; + + $scope.currentModule = null; + + divTemp.empty(); + + $('#main-panel').empty(); + }; + $rootScope.$on('loadingStatusActive', function(event, args){ $('body').modalmanager('loading'); diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/SearchForm/SearchController.js b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/SearchForm/SearchController.js index a1b71c59..bd18388b 100644 --- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/SearchForm/SearchController.js +++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/SearchForm/SearchController.js @@ -55,8 +55,9 @@ $scope.dadosTrabalhador = null; $scope.storeFichasTrabalhador.items = []; - //$scope.comboEstabelecimentos.clear(); - //$scope.comboTrabalhadores.clear(); + $scope.comboEmpresas.setValue(null); + $scope.comboEstabelecimentos.clear(); + $scope.comboTrabalhadores.clear(); }; $scope.onEmpresaChange = function(selectedValue, selectedRecord){ @@ -74,7 +75,8 @@ }; $scope.onEstabelecimentoChange = function(selectedValue, selectedRecord){ - + + $scope.comboTrabalhadores.setValue(null); $scope.comboTrabalhadores.clear(); $scope.comboTrabalhadores.store.extraParams = { @@ -106,7 +108,7 @@ }; $scope.$on('afterrender', function(event, args){ - + $scope.comboEmpresas.loadStore(function(response, status, headers, config, items){ }); diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/SearchForm/SearchView.html b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/SearchForm/SearchView.html index b3dc4acb..454c0c6b 100644 --- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/SearchForm/SearchView.html +++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/SearchForm/SearchView.html @@ -83,36 +83,48 @@ - - - - - - - - - - - - - - - - - -
Autor 
- -
+
+
+
+ +

Fichas

+ + + + + + + + + + + + + + + + + + +
Autor 
+ +
+ +
+
-
-
- +
@@ -123,8 +135,6 @@ - - diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/directives/customCombo.js b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/directives/customCombo.js index 1d8ae5c2..ad2ef9e8 100644 --- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/directives/customCombo.js +++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/directives/customCombo.js @@ -91,16 +91,43 @@ evoapp.directive('customCombo', function() { }); }; - $scope.setValue = function(newValue){ + $scope.setValue = function(newValue){ + + var option = $scope.domEl.find('option[value=' + newValue + ']'); - //$scope.$apply(function () { - - // $scope.selectedValue = newValue; - //}); + if(option.length > 0) + { + var record = angular.element(option[0]).scope(); + + if(record) + { + $($scope.domEl).val(newValue); + $($scope.domEl).select2( + 'val', newValue + ); + + //TODO: this might throw an exception - recheck it please + if($scope.bindToModel === 'true') + { + $scope.selectedValue = newValue; + $scope.selectedRecord = record.item; + } + + $scope.onChange({ + selectedValue: newValue, + selectedRecord: record.item + }); - $scope.selectedValue = newValue; - - $($scope.domEl).select2('data', newValue); + $scope.domEl.blur(); + } + } + else + { + $($scope.domEl).val(newValue); + $($scope.domEl).select2( + 'val', newValue + ); + } }; $scope.loadData = function(data){ @@ -115,11 +142,10 @@ evoapp.directive('customCombo', function() { $scope.clear = function(){ - $timeout(function () { - - $scope.store.items = []; - $($scope.domEl).select2('data', null); - }); + $scope.store.items = []; + $scope.domEl.select2('data', null); + + $scope.domEl.find('option').remove(); }; }, link: function (scope, elem, attrs, controller) { @@ -133,8 +159,9 @@ evoapp.directive('customCombo', function() { scope.domEl.attr('name', scope.name); $(scope.domEl).select2({ - allowClear: true - }).on("change", function(e) { + allowClear: true, + selectOnBlur: true + }).on('change', function(e) { var record = angular.element($(this).find("option:selected")).scope(); diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/directives/datatable.js b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/directives/datatable.js index faa35bd7..e6472c22 100644 --- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/directives/datatable.js +++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/directives/datatable.js @@ -19,7 +19,7 @@ if(scope.firstLoad) { - scope.domEl.hide(); + //scope.domEl.hide(); } scope.rows = []; @@ -42,7 +42,7 @@ if(newVal.length > 0) { //scope.noRecordsEl.hide(); - scope.domEl.show(); + //scope.domEl.show(); scope.renderTable(); } @@ -51,7 +51,7 @@ { //scope.noRecordsEl.insertAfter(scope.domEl); - scope.domEl.hide(); + //scope.domEl.hide(); //scope.noRecordsEl.show(); } }); diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/directives/datepicker.js b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/directives/datepicker.js index 6dd15108..96315972 100644 --- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/directives/datepicker.js +++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/directives/datepicker.js @@ -14,8 +14,7 @@ evoapp.directive('datepicker', function($timeout, $filter, globals) { options = {}; return { - restrict: 'A', - require: '?ngModel', + require:'?ngModel', link : function (scope, element, attrs, controller) { //convert angularjs formats to jquery format @@ -28,6 +27,34 @@ evoapp.directive('datepicker', function($timeout, $filter, globals) { if (controller) { + controller.$formatters.push(function(value) { + if (angular.isString(value) ) { + return jQuery.datepicker.parseDate(dateFormat, value); + } + return null; + }); + controller.$parsers.push(function(value){ + if (value) { + return jQuery.datepicker.formatDate(dateFormat, value); + } + return null; + }); + + //http://jsfiddle.net/FVfSL/ + //// Default to ISO formatting + //controller.$formatters.push(function(value) { + // if (angular.isString(value) ) { + // return new Date(value); + // } + // return null; + //}); + //controller.$parsers.push(function(value){ + // if (value) { + // return value.toISOString(); + // } + // return null; + //}); + controller.$render = function () { var date = controller.$viewValue; @@ -51,8 +78,8 @@ evoapp.directive('datepicker', function($timeout, $filter, globals) { firstDay: 1, - timeFormat: showTime ? timeFormat : '',//HH:mm - dateFormat: dateFormat,//dd-mm-yy + timeFormat: showTime ? timeFormat : '', + dateFormat: dateFormat, stepHour: 1, stepMinute: 5, @@ -116,7 +143,7 @@ evoapp.directive('datepicker', function($timeout, $filter, globals) { }); scope.domEl = $(element); - + if(attrs.itemId != undefined) { //TODO: this might differ - scope might refer to the controller and in other places refer to this only! @@ -139,4 +166,8 @@ evoapp.directive('datepicker', function($timeout, $filter, globals) { } } } -}); \ No newline at end of file +}); + + + + diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/services/DataService.js b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/services/DataService.js index 819b20bf..4ba83819 100644 --- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/services/DataService.js +++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/services/DataService.js @@ -76,7 +76,7 @@ { //response.data = me.convertToModel ? modelService.collectionToModel(me.model, response.data, null) : response.data; me.total = response.total; - me.items = response.data; + me.items = response.data; } callback(callbackFn, [response, status, headers, config, me.items]); diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/services/Globals.js b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/services/Globals.js index 9559fcf4..9ea9fda0 100644 --- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/services/Globals.js +++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/services/Globals.js @@ -1,4 +1,4 @@ - evoapp.factory('globals', function($rootScope, plugins, utils, message, settings, dataService, modelService) { + evoapp.factory('globals', function($rootScope, plugins, utils, message, settings, dataService, modelService, staticData) { var me = this; @@ -8,6 +8,7 @@ message: message, settings: settings.settings, dataService: dataService, - modelService: modelService + modelService: modelService, + staticData: staticData }; }); \ No newline at end of file diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/services/Message.js b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/services/Message.js index 31b9f4bf..716f1f85 100644 --- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/services/Message.js +++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/services/Message.js @@ -57,8 +57,23 @@ evoapp.factory('message', function($rootScope) { }); }; + var custom = function(){ + + var me = this; + + var message = arguments[0].message, + title = arguments[0].title, + buttons = arguments[0].buttons; + + bootbox.dialog({ + message: message, + buttons: buttons + }); + }; + return { confirm: confirm, - alert: alert + alert: alert, + custom: custom }; }); diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/services/Settings.js b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/services/Settings.js index 30d7d83e..d7c2aadb 100644 --- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/services/Settings.js +++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/services/Settings.js @@ -4,11 +4,11 @@ me.settings = { - //globals.settings.dateFormat - dateFormat: 'dd-MM-yyyy', + //globals.settings.dateFormat: dd-MM-yyyy | yyyy-MM-dd + dateFormat: 'yyyy-MM-dd', //globals.settings.dateTimeFormat - dateTimeFormat: 'dd-MM-yyyy HH:mm:ss', + dateTimeFormat: 'yyyy-MM-dd HH:mm:ss', //globals.settings.timeFormat timeFormat: 'H:i', @@ -18,7 +18,7 @@ //YYYY-MM-DD: /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/ //DD-MM-YYYY: /^(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}$/ - Date: /^(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}$/ + Date: /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/ } }; diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/services/StaticData.js b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/services/StaticData.js index 8a07c984..7b38366b 100644 --- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/services/StaticData.js +++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/services/StaticData.js @@ -10,7 +10,35 @@ WARNING: 'WARNING' }; + var tiposFichas = [ + { + id: 1, + descricao: 'Admissão' + }, + { + id: 2, + descricao: 'Periódica Inicial' + }, + { + id: 3, + descricao: 'Periódica' + }, + { + id: 7, + descricao: 'Ocasional' + }, + { + id: 8, + descricao: 'Enfermagem' + }, + { + id: 9, + descricao: 'Medicina Curativa' + } + ]; + return { - exceptions: exceptions + exceptions: exceptions, + tiposFichas: tiposFichas }; }); \ No newline at end of file diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/css/theme.css b/trunk/SiprpWebFichasClinicas/WebContent/static/html/css/theme.css index 7d0dc77f..d08f5d8e 100644 --- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/css/theme.css +++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/css/theme.css @@ -183,6 +183,10 @@ code { { margin-right:5px; } +.m-r-10 +{ + margin-right:10px; +} .m-t-none { margin-top:0px; @@ -192,7 +196,14 @@ code { { margin-bottom:0px; } - +.m-b-5 +{ + margin-bottom:5px; +} +.m-b-10 +{ + margin-bottom:10px; +} .p-10 { padding:10px; @@ -263,3 +274,12 @@ body.modal-open { filter: alpha(opacity=70); background: transparent!important; } + +.modal-footer { + text-align: left; +} + +.navbar-brand +{ + cursor:text; +} \ No newline at end of file diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/index.html b/trunk/SiprpWebFichasClinicas/WebContent/static/html/index.html index ed8e36bf..7078d507 100644 --- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/index.html +++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/index.html @@ -53,11 +53,13 @@ + + @@ -78,9 +80,12 @@ - + +