mirror of
https://github.com/documize/community.git
synced 2025-07-19 21:29:42 +02:00
dropdown mixin to handle dialog open/close lifecycle
This commit is contained in:
parent
3f31d6d15e
commit
4d989e2497
5 changed files with 43 additions and 15 deletions
|
@ -12,18 +12,19 @@
|
||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
import NotifierMixin from '../../mixins/notifier';
|
import NotifierMixin from '../../mixins/notifier';
|
||||||
import TooltipMixin from '../../mixins/tooltip';
|
import TooltipMixin from '../../mixins/tooltip';
|
||||||
|
import DropdownMixin from '../../mixins/dropdown';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
inject: { service }
|
inject: { service }
|
||||||
} = Ember;
|
} = Ember;
|
||||||
|
|
||||||
export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
export default Ember.Component.extend(NotifierMixin, TooltipMixin, DropdownMixin, {
|
||||||
userService: service('user'),
|
userService: service('user'),
|
||||||
categoryService: service('category'),
|
categoryService: service('category'),
|
||||||
appMeta: service(),
|
appMeta: service(),
|
||||||
store: service(),
|
store: service(),
|
||||||
newCategory: '',
|
newCategory: '',
|
||||||
drop: null,
|
dropdown: null,
|
||||||
users: [],
|
users: [],
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
|
@ -35,11 +36,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
let drop = this.get('drop');
|
this.destroyDropdown();
|
||||||
|
|
||||||
if (is.not.null(drop)) {
|
|
||||||
drop.destroy();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
load() {
|
load() {
|
||||||
|
@ -131,13 +128,13 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
||||||
},
|
},
|
||||||
|
|
||||||
onShowAccessPicker(catId) {
|
onShowAccessPicker(catId) {
|
||||||
|
this.closeDropdown();
|
||||||
let users = this.get('users');
|
let users = this.get('users');
|
||||||
let category = this.get('category').findBy('id', catId);
|
let category = this.get('category').findBy('id', catId);
|
||||||
|
|
||||||
this.get('categoryService').getViewers(category.get('id')).then((viewers) => {
|
this.get('categoryService').getViewers(category.get('id')).then((viewers) => {
|
||||||
// mark those users as selected that have already been given permission
|
// mark those users as selected that have already been given permission
|
||||||
// to see the current category;
|
// to see the current category;
|
||||||
console.log(viewers);
|
|
||||||
|
|
||||||
users.forEach((user) => {
|
users.forEach((user) => {
|
||||||
let selected = viewers.isAny('id', user.get('id'));
|
let selected = viewers.isAny('id', user.get('id'));
|
||||||
|
@ -162,13 +159,12 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
||||||
remove: false
|
remove: false
|
||||||
});
|
});
|
||||||
|
|
||||||
this.set('drop', drop);
|
this.set('dropdown', drop);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onGrantCancel() {
|
onGrantCancel() {
|
||||||
let drop = this.get('drop');
|
this.closeDropdown();
|
||||||
drop.close();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onGrantAccess() {
|
onGrantAccess() {
|
||||||
|
@ -189,8 +185,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
||||||
|
|
||||||
this.get('categoryService').setViewers(category.get('id'), viewers).then( () => {});
|
this.get('categoryService').setViewers(category.get('id'), viewers).then( () => {});
|
||||||
|
|
||||||
let drop = this.get('drop');
|
this.closeDropdown();
|
||||||
drop.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
30
gui/app/mixins/dropdown.js
Normal file
30
gui/app/mixins/dropdown.js
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
// 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 Ember from 'ember';
|
||||||
|
|
||||||
|
export default Ember.Mixin.create({
|
||||||
|
closeDropdown() {
|
||||||
|
let drop = this.get('dropdown');
|
||||||
|
|
||||||
|
if (is.not.null(drop) && is.not.null(drop.drop)) {
|
||||||
|
drop.close();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
destroyDropdown() {
|
||||||
|
let drop = this.get('dropdown');
|
||||||
|
|
||||||
|
if (is.not.null(drop) && is.not.null(drop.drop)) {
|
||||||
|
drop.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
|
@ -40,11 +40,12 @@
|
||||||
.content {
|
.content {
|
||||||
> p {
|
> p {
|
||||||
margin: 7px 0;
|
margin: 7px 0;
|
||||||
font-size: 0.9em;
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
> .heading {
|
> .heading {
|
||||||
font-weight: bold;
|
line-height: 3rem;
|
||||||
|
font-size: 1.2rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
> .options {
|
> .options {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
max-height: 400px;
|
max-height: 400px;
|
||||||
|
margin: 0 auto;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
|
||||||
> .option {
|
> .option {
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
|
|
||||||
<div class="dropdown-dialog category-access-dialog">
|
<div class="dropdown-dialog category-access-dialog">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
<p class="heading">Select who can view documents within category</p>
|
||||||
{{ui/ui-list-picker items=categoryUsers nameField='fullname'}}
|
{{ui/ui-list-picker items=categoryUsers nameField='fullname'}}
|
||||||
</div>
|
</div>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue