mirror of
https://github.com/documize/community.git
synced 2025-07-23 15:19:42 +02:00
Fix user edit and adding document section
This commit is contained in:
parent
abac9347e1
commit
052ffa3090
8 changed files with 91 additions and 63 deletions
|
@ -1,11 +1,11 @@
|
|||
// 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
|
||||
|
||||
|
@ -54,7 +54,8 @@ export default Ember.Component.extend({
|
|||
let self = this;
|
||||
|
||||
let user = this.users.findBy("id", id);
|
||||
this.set('editUser', user.copy());
|
||||
let userCopy = user.getProperties('id', 'created', 'revised', 'firstname', 'lastname', 'email', 'initials', 'active', 'editor', 'admin', 'accounts');
|
||||
this.set('editUser', userCopy);
|
||||
this.set('password', {
|
||||
password: "",
|
||||
confirmation: ""
|
||||
|
@ -112,15 +113,15 @@ export default Ember.Component.extend({
|
|||
let user = this.get('editUser');
|
||||
let password = this.get('password');
|
||||
|
||||
if (is.empty(user.get('firstname'))) {
|
||||
if (is.empty(user.firstname)) {
|
||||
$("#edit-firstname").addClass("error").focus();
|
||||
return;
|
||||
}
|
||||
if (is.empty(user.get('lastname'))) {
|
||||
if (is.empty(user.lastname)) {
|
||||
$("#edit-lastname").addClass("error").focus();
|
||||
return;
|
||||
}
|
||||
if (is.empty(user.get('email'))) {
|
||||
if (is.empty(user.email)) {
|
||||
$("#edit-email").addClass("error").focus();
|
||||
return;
|
||||
}
|
||||
|
@ -144,4 +145,4 @@ export default Ember.Component.extend({
|
|||
this.attrs.onDelete(user);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -25,8 +25,6 @@ export default Model.extend({
|
|||
body: attr('string'),
|
||||
rawBody: attr('string'),
|
||||
meta: attr(),
|
||||
created: attr(),
|
||||
revised: attr(),
|
||||
|
||||
tagName: Ember.computed('level', function () {
|
||||
return "h" + this.get('level');
|
||||
|
@ -39,5 +37,7 @@ export default Model.extend({
|
|||
tocIndentCss: Ember.computed('tocIndent', function () {
|
||||
let tocIndent = this.get('tocIndent');
|
||||
return `margin-left-${tocIndent}`;
|
||||
})
|
||||
}),
|
||||
created: attr(),
|
||||
revised: attr()
|
||||
});
|
||||
|
|
|
@ -34,22 +34,5 @@ export default Model.extend({
|
|||
let first = this.get('firstname').trim();
|
||||
let last = this.get('lastname').trim();
|
||||
this.set('initials', first.substr(0, 1) + last.substr(0, 1));
|
||||
},
|
||||
//
|
||||
// copy() {
|
||||
// let copy = UserModel.create();
|
||||
// copy.id = this.id;
|
||||
// copy.created = this.created;
|
||||
// copy.revised = this.revised;
|
||||
// copy.firstname = this.firstname;
|
||||
// copy.lastname = this.lastname;
|
||||
// copy.email = this.email;
|
||||
// copy.initials = this.initials;
|
||||
// copy.active = this.active;
|
||||
// copy.editor = this.editor;
|
||||
// copy.admin = this.admin;
|
||||
// copy.accounts = this.accounts;
|
||||
//
|
||||
// return copy;
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
|
|
@ -3,47 +3,56 @@ import models from '../../../utils/model';
|
|||
import NotifierMixin from '../../../mixins/notifier';
|
||||
|
||||
export default Ember.Controller.extend(NotifierMixin, {
|
||||
documentService: Ember.inject.service('document'),
|
||||
documentService: Ember.inject.service('document'),
|
||||
|
||||
actions: {
|
||||
onCancel() {
|
||||
this.transitionToRoute('document');
|
||||
},
|
||||
actions: {
|
||||
onCancel() {
|
||||
this.transitionToRoute('document');
|
||||
},
|
||||
|
||||
onAddSection(section) {
|
||||
onAddSection(section) {
|
||||
let self = this;
|
||||
debugger;
|
||||
|
||||
console.log(section.get('contentType'));
|
||||
|
||||
this.audit.record("added-section");
|
||||
this.audit.record("added-section-" + section.contentType);
|
||||
this.audit.record("added-section-" + section.get('contentType'));
|
||||
|
||||
let page = models.PageModel.create({
|
||||
documentId: this.get('model.document.id'),
|
||||
title: `${section.title} Section`,
|
||||
level: 1,
|
||||
sequence: 2048,
|
||||
body: "",
|
||||
contentType: section.contentType
|
||||
});
|
||||
let page = {
|
||||
documentId: this.get('model.document.id'),
|
||||
title: `${section.get('contentType')} Section`,
|
||||
level: 1,
|
||||
sequence: 2048,
|
||||
body: "",
|
||||
contentType: section.get('contentType')
|
||||
};
|
||||
|
||||
let meta = models.PageMetaModel.create({
|
||||
documentId: this.get('model.document.id'),
|
||||
rawBody: "",
|
||||
config: ""
|
||||
});
|
||||
let data = this.get('store').normalize('page', page);
|
||||
let pageData = this.get('store').push({ data: data });
|
||||
|
||||
let model = {
|
||||
page: page,
|
||||
meta: meta
|
||||
};
|
||||
let meta = {
|
||||
documentId: this.get('model.document.id'),
|
||||
rawBody: "",
|
||||
config: ""
|
||||
};
|
||||
|
||||
this.get('documentService').addPage(this.get('model.document.id'), model).then(function(newPage) {
|
||||
self.transitionToRoute('document.edit',
|
||||
self.get('model.folder.id'),
|
||||
self.get('model.folder.slug'),
|
||||
self.get('model.document.id'),
|
||||
self.get('model.document.slug'),
|
||||
newPage.id);
|
||||
});
|
||||
}
|
||||
}
|
||||
let metaData = this.get('store').normalize('page-meta', meta);
|
||||
let pageMetaData = this.get('store').push({ data: metaData });
|
||||
|
||||
let model = {
|
||||
page: pageData,
|
||||
meta: pageMetaData
|
||||
};
|
||||
|
||||
this.get('documentService').addPage(this.get('model.document.id'), model).then((newPage) => {
|
||||
this.transitionToRoute('document.edit',
|
||||
this.get('model.folder.id'),
|
||||
this.get('model.folder.slug'),
|
||||
this.get('model.document.id'),
|
||||
this.get('model.document.slug'),
|
||||
newPage.id);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
11
app/app/serializers/page-meta.js
Normal file
11
app/app/serializers/page-meta.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
import ApplicationSerializer from './application';
|
||||
|
||||
export default ApplicationSerializer.extend({
|
||||
normalize(modelClass, resourceHash) {
|
||||
return {
|
||||
id: resourceHash.id ? resourceHash.id : resourceHash.documentId,
|
||||
type: modelClass.modelName,
|
||||
attributes: resourceHash
|
||||
};
|
||||
}
|
||||
});
|
11
app/app/serializers/page.js
Normal file
11
app/app/serializers/page.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
import ApplicationSerializer from './application';
|
||||
|
||||
export default ApplicationSerializer.extend({
|
||||
normalize(modelClass, resourceHash) {
|
||||
return {
|
||||
id: resourceHash.id ? resourceHash.id : resourceHash.documentId,
|
||||
type: modelClass.modelName,
|
||||
attributes: resourceHash
|
||||
};
|
||||
}
|
||||
});
|
13
app/app/serializers/protected-folder-participant.js
Normal file
13
app/app/serializers/protected-folder-participant.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
import ApplicationSerializer from './application';
|
||||
|
||||
export default ApplicationSerializer.extend({
|
||||
normalize(modelClass, resourceHash) {
|
||||
return {
|
||||
data: {
|
||||
id: resourceHash.id ? resourceHash.id : resourceHash.folderId + resourceHash.userId,
|
||||
type: modelClass.modelName,
|
||||
attributes: resourceHash
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
|
@ -76,7 +76,7 @@ export default Ember.Service.extend({
|
|||
|
||||
// Updates an existing user record.
|
||||
save(user) {
|
||||
let userId = user.get('id');
|
||||
let userId = user.id;
|
||||
let url = `users/${userId}`;
|
||||
|
||||
return this.get('ajax').request(url, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue