|
@@ -7,6 +7,7 @@ let string_similarity = require('string-similarity');
|
|
require('../thirdparty/naturalSort');
|
|
require('../thirdparty/naturalSort');
|
|
|
|
|
|
require('angular').module('Ks').controller('RootController', function ($scope, $mdPanel) {
|
|
require('angular').module('Ks').controller('RootController', function ($scope, $mdPanel) {
|
|
|
|
+ $scope._ = _;
|
|
|
|
|
|
let tabCats = {
|
|
let tabCats = {
|
|
0: [1, 5],
|
|
0: [1, 5],
|
|
@@ -54,8 +55,8 @@ require('angular').module('Ks').controller('RootController', function ($scope, $
|
|
openMergeDialog(undefined, Array.from($scope.table.selected).map(id => $scope.table.items[id]))
|
|
openMergeDialog(undefined, Array.from($scope.table.selected).map(id => $scope.table.items[id]))
|
|
};
|
|
};
|
|
|
|
|
|
- $scope.selectTableRow = function (row) {
|
|
|
|
- let i = _.findIndex($scope.table.itemList, i => i.id == row);
|
|
|
|
|
|
+ $scope.selectTableRow = function (id) {
|
|
|
|
+ let i = _.findIndex($scope.table.itemList, i => i.id == id);
|
|
i++;
|
|
i++;
|
|
while (i < $scope.table.itemList.length && $scope.table.itemList[i].lev > 0.5) {
|
|
while (i < $scope.table.itemList.length && $scope.table.itemList[i].lev > 0.5) {
|
|
if ($scope.table.itemList[i].class === 'file') $scope.table.selected.push($scope.table.itemList[i].id);
|
|
if ($scope.table.itemList[i].class === 'file') $scope.table.selected.push($scope.table.itemList[i].id);
|
|
@@ -63,6 +64,11 @@ require('angular').module('Ks').controller('RootController', function ($scope, $
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ $scope.triggerTableRow = function (id) {
|
|
|
|
+ $scope.table.selected.push(id);
|
|
|
|
+ $scope.selectTableRow(id);
|
|
|
|
+ };
|
|
|
|
+
|
|
const defaultPanel = {
|
|
const defaultPanel = {
|
|
panelClass: 'item-dialog',
|
|
panelClass: 'item-dialog',
|
|
controllerAs: 'ctrl',
|
|
controllerAs: 'ctrl',
|
|
@@ -80,17 +86,54 @@ require('angular').module('Ks').controller('RootController', function ($scope, $
|
|
controller: ["$mdToast", "$http", "mdPanelRef", "$timeout", function ($mdToast, $http, mdPanelRef, $timeout) {
|
|
controller: ["$mdToast", "$http", "mdPanelRef", "$timeout", function ($mdToast, $http, mdPanelRef, $timeout) {
|
|
var ctrl = this;
|
|
var ctrl = this;
|
|
ctrl._ = _;
|
|
ctrl._ = _;
|
|
- ctrl.new = _.isUndefined(id);
|
|
|
|
|
|
+ ctrl.items = items;
|
|
|
|
|
|
- if (ctrl.new) {
|
|
|
|
- ctrl.item = {
|
|
|
|
- name: _.first(items).name,
|
|
|
|
- files: _.map(items, i => i.id)
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- //ctrl.item = _.extend({}, item);
|
|
|
|
|
|
+ ctrl.item = {};
|
|
|
|
+
|
|
|
|
+ function resetItem() {
|
|
|
|
+ ctrl.item.files = _.uniq(_.map(items, i => i.id));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ ctrl.ac = {
|
|
|
|
+ group: {
|
|
|
|
+ selected: null,
|
|
|
|
+ search: null,
|
|
|
|
+ query: function (q) {
|
|
|
|
+ return new Promise((rs, rj) => {
|
|
|
|
+ $timeout(() => {
|
|
|
|
+ let candidates = ipc.sendSync('get:groups:find', q);
|
|
|
|
+ if (_.isEmpty(candidates)) candidates.push({fake: true, name: q, files: []});
|
|
|
|
+ rs(candidates)
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ init: function (id) {
|
|
|
|
+ if (_.isUndefined(id)) {
|
|
|
|
+ let name = ctrl.item.name = this.search = _.first(_.map(items, i => i.name));
|
|
|
|
+ this.selected = {fake: true, name: name, files: []};
|
|
|
|
+ resetItem();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ change: function () {
|
|
|
|
+ resetItem();
|
|
|
|
+ if (_.isObject(this.selected)) {
|
|
|
|
+ ctrl.item.name = this.selected.name;
|
|
|
|
+ if (this.selected.fake) {
|
|
|
|
+ ctrl.item.id = undefined;
|
|
|
|
+ } else {
|
|
|
|
+ ctrl.item.id = this.selected.id;
|
|
|
|
+ ctrl.item.files = _.uniq(ctrl.item.files.concat(this.selected.files));
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ ctrl.item.name = undefined;
|
|
|
|
+ ctrl.item.id = undefined;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ ctrl.ac.group.init(id);
|
|
|
|
+
|
|
ctrl.cancel = function () {
|
|
ctrl.cancel = function () {
|
|
mdPanelRef.close();
|
|
mdPanelRef.close();
|
|
};
|
|
};
|
|
@@ -99,7 +142,7 @@ require('angular').module('Ks').controller('RootController', function ($scope, $
|
|
if (itemForm.$valid) {
|
|
if (itemForm.$valid) {
|
|
ipc.sendSync('set:groups', [ctrl.item]);
|
|
ipc.sendSync('set:groups', [ctrl.item]);
|
|
mdPanelRef.close();
|
|
mdPanelRef.close();
|
|
- $timeout(_ => getPage())
|
|
|
|
|
|
+ $timeout(() => getPage())
|
|
} else {
|
|
} else {
|
|
$mdToast.showSimple('Невозможно сохранить объект. Форма заполнена неверно.')
|
|
$mdToast.showSimple('Невозможно сохранить объект. Форма заполнена неверно.')
|
|
}
|
|
}
|