Skip to content

Commit

Permalink
Merge pull request #32 from documize/ember-data-store
Browse files Browse the repository at this point in the history
Push data from services into ember data store
  • Loading branch information
HarveyKandola authored Sep 16, 2016
2 parents 44716e8 + 69e1a19 commit 8a351b8
Show file tree
Hide file tree
Showing 43 changed files with 1,092 additions and 568 deletions.
84 changes: 42 additions & 42 deletions app/app/components/document/document-sidebar-edits.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// 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>.
// by contacting <sales@documize.com>.
//
// https://documize.com

import Ember from 'ember';

export default Ember.Component.extend({
document: {},
meta: [],
pages: [],
document: {},
meta: [],
pages: [],

didReceiveAttrs() {
let editors = this.get('meta.editors');
let toc = this.get('pages');
didReceiveAttrs() {
let editors = this.get('meta.editors');
let toc = this.get('pages');

if (is.null(editors)) {
return;
}
if (is.null(editors)) {
return;
}

editors.forEach(function(item) {
Ember.set(item, "added", item.action === "add-page");
Ember.set(item, "changed", item.action === "update-page");
Ember.set(item, "deleted", item.action === "remove-page");
editors.forEach(function (item) {
Ember.set(item, "added", item.action === "add-page");
Ember.set(item, "changed", item.action === "update-page");
Ember.set(item, "deleted", item.action === "remove-page");

let page = _.findWhere(toc, {
id: item.pageId
});
let title = "";
let page = _.findWhere(toc, {
id: item.pageId
});
let title = "";

if (is.not.undefined(page)) {
title = page.title;
if (is.not.undefined(page)) {
title = page.get('title');

if (item.added) {
Ember.set(item, 'changeLabel', "added " + title);
}
if (item.added) {
Ember.set(item, 'changeLabel', "added " + title);
}

if (item.changed) {
Ember.set(item, 'changeLabel', "changed " + title);
}
} else {
Ember.set(item, "deleted", true);
if (item.changed) {
Ember.set(item, 'changeLabel', "changed " + title);
}
} else {
Ember.set(item, "deleted", true);

if (item.added) {
Ember.set(item, 'changeLabel', "added section (since removed)");
}
if (item.added) {
Ember.set(item, 'changeLabel', "added section (since removed)");
}

if (item.changed) {
Ember.set(item, 'changeLabel', "changed section (since removed)");
}
if (item.changed) {
Ember.set(item, 'changeLabel', "changed section (since removed)");
}

if (item.deleted) {
Ember.set(item, 'changeLabel', "removed section");
}
}
});
}
});
if (item.deleted) {
Ember.set(item, 'changeLabel', "removed section");
}
}
});
}
});
194 changes: 99 additions & 95 deletions app/app/components/folder/folder-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,100 +11,104 @@

import Ember from 'ember';

const {
inject: { service }
} = Ember;

export default Ember.Component.extend({
folderService: Ember.inject.service('folder'),
appMeta: Ember.inject.service(),
users: [],
folders: [],
folder: {},
moveTarget: null,
inviteEmail: "",
inviteMessage: "",
roleMessage: "",
permissions: {},

getDefaultInvitationMessage() {
return "Hey there, I am sharing the " + this.folder.get('name') + " (in " + this.get("appMeta.title") + ") with you so we can both access the same documents.";
},

willRender() {
if (this.inviteMessage.length === 0) {
this.set('inviteMessage', this.getDefaultInvitationMessage());
}

if (this.roleMessage.length === 0) {
this.set('roleMessage', this.getDefaultInvitationMessage());
}
},

actions: {
rename() {
if (is.empty(this.folder.get('name'))) {
$("#folderName").addClass("error").focus();
return;
}

this.sendAction("onRename", this.folder);
},

remove() {
if (is.null(this.get('moveTarget'))) {
$("#delete-target > select").addClass("error").focus();
return;
}

this.sendAction("onRemove", this.get('moveTarget').get('id'));
},

share() {
var email = this.get('inviteEmail').trim().replace(/ /g, '');
var message = this.get('inviteMessage').trim();

if (message.length === 0) {
message = this.getDefaultInvitationMessage();
}

if (email.length === 0) {
$("#inviteEmail").addClass("error").focus();
return;
}

var result = {
Message: message,
Recipients: []
};

// Check for multiple email addresses
if (email.indexOf(",") > -1) {
result.Recipients = email.split(',');
}
if (email.indexOf(";") > -1 && result.Recipients.length === 0) {
result.Recipients = email.split(';');
}

// Handle just one email address
if (result.Recipients.length === 0 && email.length > 0) {
result.Recipients.push(email);
}

this.set('inviteEmail', "");

this.sendAction("onShare", result);
},

setPermissions() {
var message = this.get('roleMessage').trim();

if (message.length === 0) {
message = this.getDefaultInvitationMessage();
}

this.get('permissions').forEach(function(permission, index) /* jshint ignore:line */ {
Ember.set(permission, 'canView', $("#canView-" + permission.userId).prop('checked'));
Ember.set(permission, 'canEdit', $("#canEdit-" + permission.userId).prop('checked'));
});

this.sendAction("onPermission", this.get('folder'), message, this.get('permissions'));
}
}
folderService: service('folder'),
appMeta: service(),
users: [],
folders: [],
folder: {},
moveTarget: null,
inviteEmail: "",
inviteMessage: "",
roleMessage: "",
permissions: {},

getDefaultInvitationMessage() {
return "Hey there, I am sharing the " + this.folder.get('name') + " (in " + this.get("appMeta.title") + ") with you so we can both access the same documents.";
},

willRender() {
if (this.inviteMessage.length === 0) {
this.set('inviteMessage', this.getDefaultInvitationMessage());
}

if (this.roleMessage.length === 0) {
this.set('roleMessage', this.getDefaultInvitationMessage());
}
},

actions: {
rename() {
if (is.empty(this.folder.get('name'))) {
$("#folderName").addClass("error").focus();
return;
}

this.sendAction("onRename", this.folder);
},

remove() {
if (is.null(this.get('moveTarget'))) {
$("#delete-target > select").addClass("error").focus();
return;
}

this.sendAction("onRemove", this.get('moveTarget').get('id'));
},

share() {
var email = this.get('inviteEmail').trim().replace(/ /g, '');
var message = this.get('inviteMessage').trim();

if (message.length === 0) {
message = this.getDefaultInvitationMessage();
}

if (email.length === 0) {
$("#inviteEmail").addClass("error").focus();
return;
}

var result = {
Message: message,
Recipients: []
};

// Check for multiple email addresses
if (email.indexOf(",") > -1) {
result.Recipients = email.split(',');
}
if (email.indexOf(";") > -1 && result.Recipients.length === 0) {
result.Recipients = email.split(';');
}

// Handle just one email address
if (result.Recipients.length === 0 && email.length > 0) {
result.Recipients.push(email);
}

this.set('inviteEmail', "");

this.sendAction("onShare", result);
},

setPermissions() {
var message = this.get('roleMessage').trim();

if (message.length === 0) {
message = this.getDefaultInvitationMessage();
}

this.get('permissions').forEach((permission, index) => { /* jshint ignore:line */
Ember.set(permission, 'canView', $("#canView-" + permission.userId).prop('checked'));
Ember.set(permission, 'canEdit', $("#canEdit-" + permission.userId).prop('checked'));
});

this.sendAction("onPermission", this.get('folder'), message, this.get('permissions'));
}
}
});
Loading

0 comments on commit 8a351b8

Please sign in to comment.