mirror of
https://github.com/documize/community.git
synced 2025-07-24 23:59:47 +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.
|
// 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
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
@ -54,7 +54,8 @@ export default Ember.Component.extend({
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
let user = this.users.findBy("id", id);
|
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', {
|
this.set('password', {
|
||||||
password: "",
|
password: "",
|
||||||
confirmation: ""
|
confirmation: ""
|
||||||
|
@ -112,15 +113,15 @@ export default Ember.Component.extend({
|
||||||
let user = this.get('editUser');
|
let user = this.get('editUser');
|
||||||
let password = this.get('password');
|
let password = this.get('password');
|
||||||
|
|
||||||
if (is.empty(user.get('firstname'))) {
|
if (is.empty(user.firstname)) {
|
||||||
$("#edit-firstname").addClass("error").focus();
|
$("#edit-firstname").addClass("error").focus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (is.empty(user.get('lastname'))) {
|
if (is.empty(user.lastname)) {
|
||||||
$("#edit-lastname").addClass("error").focus();
|
$("#edit-lastname").addClass("error").focus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (is.empty(user.get('email'))) {
|
if (is.empty(user.email)) {
|
||||||
$("#edit-email").addClass("error").focus();
|
$("#edit-email").addClass("error").focus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -144,4 +145,4 @@ export default Ember.Component.extend({
|
||||||
this.attrs.onDelete(user);
|
this.attrs.onDelete(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -25,8 +25,6 @@ export default Model.extend({
|
||||||
body: attr('string'),
|
body: attr('string'),
|
||||||
rawBody: attr('string'),
|
rawBody: attr('string'),
|
||||||
meta: attr(),
|
meta: attr(),
|
||||||
created: attr(),
|
|
||||||
revised: attr(),
|
|
||||||
|
|
||||||
tagName: Ember.computed('level', function () {
|
tagName: Ember.computed('level', function () {
|
||||||
return "h" + this.get('level');
|
return "h" + this.get('level');
|
||||||
|
@ -39,5 +37,7 @@ export default Model.extend({
|
||||||
tocIndentCss: Ember.computed('tocIndent', function () {
|
tocIndentCss: Ember.computed('tocIndent', function () {
|
||||||
let tocIndent = this.get('tocIndent');
|
let tocIndent = this.get('tocIndent');
|
||||||
return `margin-left-${tocIndent}`;
|
return `margin-left-${tocIndent}`;
|
||||||
})
|
}),
|
||||||
|
created: attr(),
|
||||||
|
revised: attr()
|
||||||
});
|
});
|
||||||
|
|
|
@ -34,22 +34,5 @@ export default Model.extend({
|
||||||
let first = this.get('firstname').trim();
|
let first = this.get('firstname').trim();
|
||||||
let last = this.get('lastname').trim();
|
let last = this.get('lastname').trim();
|
||||||
this.set('initials', first.substr(0, 1) + last.substr(0, 1));
|
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';
|
import NotifierMixin from '../../../mixins/notifier';
|
||||||
|
|
||||||
export default Ember.Controller.extend(NotifierMixin, {
|
export default Ember.Controller.extend(NotifierMixin, {
|
||||||
documentService: Ember.inject.service('document'),
|
documentService: Ember.inject.service('document'),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
onCancel() {
|
onCancel() {
|
||||||
this.transitionToRoute('document');
|
this.transitionToRoute('document');
|
||||||
},
|
},
|
||||||
|
|
||||||
onAddSection(section) {
|
onAddSection(section) {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
debugger;
|
||||||
|
|
||||||
|
console.log(section.get('contentType'));
|
||||||
|
|
||||||
this.audit.record("added-section");
|
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({
|
let page = {
|
||||||
documentId: this.get('model.document.id'),
|
documentId: this.get('model.document.id'),
|
||||||
title: `${section.title} Section`,
|
title: `${section.get('contentType')} Section`,
|
||||||
level: 1,
|
level: 1,
|
||||||
sequence: 2048,
|
sequence: 2048,
|
||||||
body: "",
|
body: "",
|
||||||
contentType: section.contentType
|
contentType: section.get('contentType')
|
||||||
});
|
};
|
||||||
|
|
||||||
let meta = models.PageMetaModel.create({
|
let data = this.get('store').normalize('page', page);
|
||||||
documentId: this.get('model.document.id'),
|
let pageData = this.get('store').push({ data: data });
|
||||||
rawBody: "",
|
|
||||||
config: ""
|
|
||||||
});
|
|
||||||
|
|
||||||
let model = {
|
let meta = {
|
||||||
page: page,
|
documentId: this.get('model.document.id'),
|
||||||
meta: meta
|
rawBody: "",
|
||||||
};
|
config: ""
|
||||||
|
};
|
||||||
|
|
||||||
this.get('documentService').addPage(this.get('model.document.id'), model).then(function(newPage) {
|
let metaData = this.get('store').normalize('page-meta', meta);
|
||||||
self.transitionToRoute('document.edit',
|
let pageMetaData = this.get('store').push({ data: metaData });
|
||||||
self.get('model.folder.id'),
|
|
||||||
self.get('model.folder.slug'),
|
let model = {
|
||||||
self.get('model.document.id'),
|
page: pageData,
|
||||||
self.get('model.document.slug'),
|
meta: pageMetaData
|
||||||
newPage.id);
|
};
|
||||||
});
|
|
||||||
}
|
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.
|
// Updates an existing user record.
|
||||||
save(user) {
|
save(user) {
|
||||||
let userId = user.get('id');
|
let userId = user.id;
|
||||||
let url = `users/${userId}`;
|
let url = `users/${userId}`;
|
||||||
|
|
||||||
return this.get('ajax').request(url, {
|
return this.get('ajax').request(url, {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue