mirror of
https://github.com/documize/community.git
synced 2025-07-24 15:49:44 +02:00
More UI conversion to new framework
This commit is contained in:
parent
a453052087
commit
5d757c992f
17 changed files with 442 additions and 416 deletions
45
gui/app/components/folder/category-admin-sidebar.js
Normal file
45
gui/app/components/folder/category-admin-sidebar.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
import $ from 'jquery';
|
||||
import Component from '@ember/component';
|
||||
|
||||
export default Component.extend({
|
||||
newCategory: '',
|
||||
|
||||
actions: {
|
||||
didInsertElement() {
|
||||
this._super(...arguments);
|
||||
$('#new-category-name').focus();
|
||||
},
|
||||
|
||||
onAdd(e) {
|
||||
e.preventDefault();
|
||||
|
||||
let cat = this.get('newCategory');
|
||||
|
||||
if (cat === '') {
|
||||
$('#new-category-name').addClass('is-invalid').focus();
|
||||
return;
|
||||
}
|
||||
|
||||
$('#new-category-name').removeClass('is-invalid').focus();
|
||||
this.set('newCategory', '');
|
||||
|
||||
let c = {
|
||||
category: cat,
|
||||
folderId: this.get('space.id')
|
||||
};
|
||||
|
||||
this.get('onAdd')(c);
|
||||
}
|
||||
}
|
||||
});
|
|
@ -22,7 +22,6 @@ export default Component.extend(ModalMixin, TooltipMixin, {
|
|||
categorySvc: service('category'),
|
||||
appMeta: service(),
|
||||
store: service(),
|
||||
newCategory: '',
|
||||
deleteId: '',
|
||||
dropdown: null,
|
||||
|
||||
|
@ -92,29 +91,6 @@ export default Component.extend(ModalMixin, TooltipMixin, {
|
|||
},
|
||||
|
||||
actions: {
|
||||
onAdd(e) {
|
||||
e.preventDefault();
|
||||
|
||||
let cat = this.get('newCategory');
|
||||
|
||||
if (cat === '') {
|
||||
$('#new-category-name').addClass('is-invalid').focus();
|
||||
return;
|
||||
}
|
||||
|
||||
$('#new-category-name').removeClass('is-invalid').focus();
|
||||
this.set('newCategory', '');
|
||||
|
||||
let c = {
|
||||
category: cat,
|
||||
folderId: this.get('folder.id')
|
||||
};
|
||||
|
||||
this.get('categorySvc').add(c).then(() => {
|
||||
this.load();
|
||||
});
|
||||
},
|
||||
|
||||
onShowDelete(id) {
|
||||
let cat = this.get('category').findBy('id', id);
|
||||
this.set('deleteId', cat.get('id'));
|
||||
|
|
|
@ -9,13 +9,12 @@
|
|||
//
|
||||
// https://documize.com
|
||||
|
||||
import Component from '@ember/component';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { all } from 'rsvp';
|
||||
import { schedule } from '@ember/runloop';
|
||||
import { gt } from '@ember/object/computed';
|
||||
import { computed } from '@ember/object';
|
||||
import AuthMixin from '../../mixins/auth';
|
||||
import Component from '@ember/component';
|
||||
|
||||
export default Component.extend(AuthMixin, {
|
||||
router: service(),
|
||||
|
@ -30,7 +29,7 @@ export default Component.extend(AuthMixin, {
|
|||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
this.filteredDocs = [];
|
||||
// this.filteredDocs = [];
|
||||
this.setup();
|
||||
},
|
||||
|
||||
|
@ -39,11 +38,6 @@ export default Component.extend(AuthMixin, {
|
|||
this.setup();
|
||||
},
|
||||
|
||||
didUpdateAttrs() {
|
||||
this._super(...arguments);
|
||||
// this.setup();
|
||||
},
|
||||
|
||||
setup() {
|
||||
let categories = this.get('categories');
|
||||
let categorySummary = this.get('categorySummary');
|
||||
|
@ -59,7 +53,7 @@ export default Component.extend(AuthMixin, {
|
|||
});
|
||||
|
||||
this.set('categories', categories);
|
||||
this.set('categoryLinkName', categories.length > 0 ? 'manage' : 'add');
|
||||
this.set('categoryLinkName', categories.length > 0 ? 'Manage' : 'Add');
|
||||
|
||||
schedule('afterRender', () => {
|
||||
if (this.get('categoryFilter') !== '') {
|
||||
|
@ -75,50 +69,6 @@ export default Component.extend(AuthMixin, {
|
|||
},
|
||||
|
||||
actions: {
|
||||
onMoveDocument(documents, targetSpaceId) {
|
||||
let self = this;
|
||||
let promises1 = [];
|
||||
let promises2 = [];
|
||||
|
||||
documents.forEach(function(documentId, index) {
|
||||
promises1[index] = self.get('documentService').getDocument(documentId);
|
||||
});
|
||||
|
||||
all(promises1).then(() => {
|
||||
promises1.forEach(function(doc, index) {
|
||||
doc.then((d) => {
|
||||
d.set('folderId', targetSpaceId);
|
||||
d.set('selected', false);
|
||||
promises2[index] = self.get('documentService').save(d);
|
||||
});
|
||||
});
|
||||
|
||||
all(promises2).then(() => {
|
||||
self.attrs.onRefresh();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
onDeleteDocument(documents) {
|
||||
let self = this;
|
||||
let promises = [];
|
||||
|
||||
documents.forEach(function (document, index) {
|
||||
promises[index] = self.get('documentService').deleteDocument(document);
|
||||
});
|
||||
|
||||
all(promises).then(() => {
|
||||
let documents = this.get('documents');
|
||||
documents.forEach(function (document) {
|
||||
document.set('selected', false);
|
||||
});
|
||||
|
||||
this.set('documents', documents);
|
||||
let cb = this.get('onRefresh');
|
||||
cb();
|
||||
});
|
||||
},
|
||||
|
||||
onDocumentFilter(filter, id) {
|
||||
let docs = this.get('documents');
|
||||
let categories = this.get('categories');
|
||||
|
@ -170,7 +120,7 @@ export default Component.extend(AuthMixin, {
|
|||
});
|
||||
|
||||
this.set('categories', categories);
|
||||
this.set('filteredDocs', filtered);
|
||||
this.get('onFiltered')(filtered);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue