From dc54cfe99f08f725455ae8c7a4fcd3dba7404d95 Mon Sep 17 00:00:00 2001 From: Daniel Petrov Date: Tue, 17 Dec 2024 17:21:06 +0200 Subject: [PATCH] fixup! WIP add ebp settings page --- .../controllers/EBPSettingsController.js | 11 +- .../controllers/EBPSpeciesController.js | 47 +++++ client/views/ebp.html | 2 +- client/views/ebp/species.html | 175 ++++++++++-------- 4 files changed, 142 insertions(+), 93 deletions(-) create mode 100644 client/scripts/controllers/EBPSpeciesController.js diff --git a/client/scripts/controllers/EBPSettingsController.js b/client/scripts/controllers/EBPSettingsController.js index e96f5f19..96058471 100644 --- a/client/scripts/controllers/EBPSettingsController.js +++ b/client/scripts/controllers/EBPSettingsController.js @@ -1,17 +1,8 @@ -require('../app').controller('EBPSettingsController', /* @ngInject */function ($q, $stateParams, EBPSpecies) { +require('../app').controller('EBPSettingsController', /* @ngInject */function ($scope, $q, $stateParams, EBPSpecies) { const $ctrl = this $ctrl.selected = 'sources' - if ($stateParams.settings) { $ctrl.selected = $stateParams.settings } - - $ctrl.requestSpecies = function () { - $q.resolve(EBPSpecies.query().$promise).then(function (species) { - $ctrl.species = species - }) - } - - $ctrl.requestSpecies() }) diff --git a/client/scripts/controllers/EBPSpeciesController.js b/client/scripts/controllers/EBPSpeciesController.js new file mode 100644 index 00000000..11d1d513 --- /dev/null +++ b/client/scripts/controllers/EBPSpeciesController.js @@ -0,0 +1,47 @@ +require('../app').controller('EBPSpeciesController', /* @ngInject */function ($scope, $q, $stateParams, EBPSpecies) { + const $ctrl = this + + $ctrl.page = 1 + $ctrl.pageSize = 20 + + $ctrl.requestSpecies = function () { + $q.resolve(EBPSpecies.query().$promise).then(function (rows) { + $ctrl.count = rows.$$response.data.$$response.count + $ctrl.species = rows + $ctrl.pageChanged() + }) + } + + $ctrl.pageChanged = function () { + const start = ($ctrl.page - 1) * $ctrl.pageSize + $ctrl.visible = $ctrl.species.slice(start, start + $ctrl.pageSize) + } + + $ctrl.remove = function (idx) { + const start = ($ctrl.page - 1) * $ctrl.pageSize + $ctrl.species.splice(start + idx, 1) + $ctrl.count = $ctrl.species.length + if (start >= $ctrl.species.length && $ctrl.page > 0) { + $ctrl.page-- + } + $ctrl.pageChanged() + $scope.editform.$setDirty() + } + + $ctrl.add = function (key) { + const len = $ctrl.species.push({ + ebpId: null, + sbNameLa: null, + sbNameEn: null + }) + $ctrl.page = Math.ceil(len / $ctrl.pageSize) + $ctrl.pageChanged() + $scope.editform.$setDirty() + } + + $ctrl.save = function () { + // TODO: save + } + + $ctrl.requestSpecies() +}) diff --git a/client/views/ebp.html b/client/views/ebp.html index c4f910e1..9ae16448 100644 --- a/client/views/ebp.html +++ b/client/views/ebp.html @@ -40,7 +40,7 @@

-
+
diff --git a/client/views/ebp/species.html b/client/views/ebp/species.html index c490c2dd..cb0ae737 100644 --- a/client/views/ebp/species.html +++ b/client/views/ebp/species.html @@ -1,82 +1,93 @@ -{{ $ctrl.species | json }} -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#EBP species codeSB name laEBP name - - -
{{$index+1+($ctrl.page-1)*$ctrl.pageSize}} - - - - - - - -
#EBP species codeSB name laEBP name - - -
-
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#EBP species codeSB name laEBP name + + +
{{$index+1+($ctrl.page-1)*$ctrl.pageSize}} + + + + + + + +
#EBP species codeSB name laEBP name + + +
+
+ +
+
    +
    +