From 7bb53c64da2dcf88894bfd31503accdd81498f3d Mon Sep 17 00:00:00 2001 From: Thomas Duval Date: Wed, 3 Jun 2020 10:06:52 +0200 Subject: Update to new version 5.4 Signed-off-by: Thomas Duval Change-Id: Idcd868133d75928a1ffd74d749ce98503e0555ea --- moon_gui/static/app/model/model.controller.list.js | 195 --------------------- 1 file changed, 195 deletions(-) delete mode 100755 moon_gui/static/app/model/model.controller.list.js (limited to 'moon_gui/static/app/model/model.controller.list.js') diff --git a/moon_gui/static/app/model/model.controller.list.js b/moon_gui/static/app/model/model.controller.list.js deleted file mode 100755 index 5021a57e..00000000 --- a/moon_gui/static/app/model/model.controller.list.js +++ /dev/null @@ -1,195 +0,0 @@ -(function() { - - 'use strict'; - - angular - .module('moon') - .controller('ModelListController', ModelListController); - - ModelListController.$inject = ['$scope', '$rootScope', 'models', 'NgTableParams', '$filter', '$modal']; - - function ModelListController($scope, $rootScope, models, NgTableParams, $filter, $modal) { - - var list = this; - - list.models = models; - - list.table = {}; - - list.search = { query: '', - find: searchModel, - reset: searchReset }; - - list.getModels = getModels; - list.hasModels = hasModels; - list.deleteModel = deleteModel; - list.refreshModels = refreshModels; - - list.add = { modal: $modal({ template: 'html/model/action/model-add.tpl.html', show: false }), - showModal: showAddModal }; - - list.view = { modal: $modal({ template: 'html/model/action/model-view.tpl.html', show: false }), - showModal: showViewModal }; - - list.del = { modal: $modal({ template: 'html/model/action/model-delete.tpl.html', show: false }), - showModal: showDeleteModal }; - - activate(); - - function activate(){ - newModelsTable(); - } - - - /* - * ---- events - */ - var rootListeners = { - - 'event:modelCreatedSuccess': $rootScope.$on('event:modelCreatedSuccess', modelCreatedSuccess), - 'event:modelCreatedError': $rootScope.$on('event:modelCreatedError', modelCreatedError), - - 'event:modelDeletedSuccess': $rootScope.$on('event:modelDeletedSuccess', modelDeletedSuccess), - 'event:modelDeletedError': $rootScope.$on('event:modelDeletedError', modelDeletedError) - - - }; - - for (var unbind in rootListeners) { - $scope.$on('$destroy', rootListeners[unbind]); - } - - - function newModelsTable() { - - list.table = new NgTableParams({ - - page: 1, // show first page - count: 10, // count per page - sorting: { - name: 'asc' // initial sorting - } - - }, { - - total: function () { return list.getModels().length; }, // length of data - getData: function($defer, params) { - - var orderedData = params.sorting() ? $filter('orderBy')(list.getModels(), params.orderBy()) : list.getModels(); - $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count())); - - }, - $scope: { $data: {} } - - }); - - return list.table; - - } - - function getModels() { - return (list.models) ? list.models : []; - } - - function hasModels() { - return list.getModels().length > 0; - } - - /** - * Blank the search field - */ - function searchReset() { - list.search.query = ''; - } - - /* - * ---- search - */ - - function searchModel(model){ - return (model.name.indexOf(list.search.query) !== -1 || model.description.indexOf(list.search.query) !== -1); - } - - /* - * ---- add - */ - function showAddModal() { - list.add.modal.$promise.then(list.add.modal.show); - } - - function addModel(model) { - list.models.push(model); - } - - /** - * Refresh the table - */ - function refreshModels(){ - list.table.total(list.models.length); - list.table.reload(); - } - - /** - * This function will add a model to the current list of models and refresh the table - * @param event - * @param model - */ - function modelCreatedSuccess(event, model) { - addModel(model); - refreshModels(); - list.add.modal.hide(); - } - - /** - * This function hide the add modal - * @param event - */ - function modelCreatedError(event) { - list.add.modal.hide(); - } - - /* - * ---- view - */ - - function showViewModal(model) { - - list.view.modal.$scope.model = model; - list.view.modal.$promise.then(list.view.modal.show); - - } - - - /* - * ---- delete - */ - - function showDeleteModal(model) { - - list.del.modal.$scope.model = model; - list.del.modal.$promise.then(list.del.modal.show); - - } - - function deleteModel(model) { - list.models = _.chain(list.models).reject({id: model.id}).value(); - } - - - function modelDeletedSuccess(event, model) { - - list.deleteModel(model); - list.refreshModels(); - - list.del.modal.hide(); - - } - - function modelDeletedError(event, model) { - list.del.modal.hide(); - } - - - } - -})(); -- cgit 1.2.3-korg