1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-02 20:15:26 +02:00

upgraded material icon fonts, space invite popup UX

This commit is contained in:
Harvey Kandola 2017-11-23 20:40:46 +00:00
parent 18fc5db8c6
commit e10313b7cc
13 changed files with 161 additions and 199 deletions

View file

@ -10,7 +10,6 @@
// https://documize.com
import { A } from '@ember/array';
import ArrayProxy from '@ember/array/proxy';
import RSVP, { Promise as EmberPromise } from 'rsvp';
import Service, { inject as service } from '@ember/service';
@ -27,26 +26,25 @@ export default Service.extend({
let userId = this.get('session.user.id');
if (!this.get('session.authenticated')) {
return new RSVP.resolve([]);
return new RSVP.resolve(A([]));
}
if (this.get('initialized')) {
return new RSVP.resolve(this.get('pins'));
}
return this.get('ajax').request(`pin/${userId}`, {
method: 'GET'
}).then((response) => {
if (is.not.array(response)) {
response = [];
}
let pins = ArrayProxy.create({
content: A([])
});
if (is.not.array(response)) response = [];
let pins = ArrayProxy.create({ content: A([]) });
pins = response.map((pin) => {
let data = this.get('store').normalize('pin', pin);
return this.get('store').push(data);
});
this.set('pins', pins);
this.set('initialized', true);
this.set('pins', pins);
return pins;
});
@ -56,6 +54,8 @@ export default Service.extend({
pinItem(data) {
let userId = this.get('session.user.id');
this.set('initialized', false);
if(this.get('session.authenticated')) {
return this.get('ajax').request(`pin/${userId}`, {
method: 'POST',
@ -71,6 +71,8 @@ export default Service.extend({
unpinItem(pinId) {
let userId = this.get('session.user.id');
this.set('initialized', false);
if(this.get('session.authenticated')) {
return this.get('ajax').request(`pin/${userId}/${pinId}`, {
method: 'DELETE'
@ -107,52 +109,34 @@ export default Service.extend({
},
isDocumentPinned(documentId) {
let userId = this.get('session.user.id');
let pins = this.get('pins');
return new EmberPromise((resolve, reject) => { // eslint-disable-line no-unused-vars
let userId = this.get('session.user.id');
return new EmberPromise((resolve) => {
if (this.get('initialized') === false) {
this.getUserPins().then((pins) => {
pins.forEach((pin) => {
if (pin.get('userId') === userId && pin.get('documentId') === documentId) {
resolve(pin.get('id'));
}
});
});
} else {
return this.getUserPins().then((pins) => {
pins.forEach((pin) => {
if (pin.get('userId') === userId && pin.get('documentId') === documentId) {
resolve(pin.get('id'));
}
});
}
resolve('');
resolve('');
});
});
},
isSpacePinned(spaceId) {
let userId = this.get('session.user.id');
let pins = this.get('pins');
return new EmberPromise((resolve, reject) => { // eslint-disable-line no-unused-vars
let userId = this.get('session.user.id');
return new EmberPromise((resolve) => {
if (!this.get('initialized')) {
this.getUserPins().then((pins) => {
return this.getUserPins().then((pins) => {
pins.forEach((pin) => {
if (pin.get('userId') === userId && pin.get('documentId') === '' && pin.get('folderId') === spaceId) {
resolve(pin.get('id'));
}
});
resolve('');
});
} else {
pins.forEach((pin) => {
if (pin.get('userId') === userId && pin.get('documentId') === '' && pin.get('folderId') === spaceId) {
resolve(pin.get('id'));
}
});
}
resolve('');
});
}
});