To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 12e0f27f authored by Hermann's avatar Hermann
Browse files

reshuffle workflow for itemcontroller view selection

parent 6d9503ce
......@@ -42,7 +42,9 @@ export default class NewBlacklist extends EditView {
beforeSubmit() {
const { data } = this.form;
// exchange user object with string of id
this.submit({ ...data, user: data.user ? data.user._id : undefined });
this.submit({ ...data, user: data.user ? data.user._id : undefined }).then(() => {
this.controller.changeModus('view');
});
}
view() {
......
......@@ -200,9 +200,9 @@ export default class newEvent extends EditView {
Object.keys(images).forEach(key => imageForm.append(key, images[key]));
imageForm.append('_id', _id);
imageForm.append('_etag', _etag);
this.controller.patch(imageForm);
this.controller.patch(imageForm).then(() => this.controller.changeModus('view'));
});
} else this.submit(data);
} else this.submit(data).then(() => this.controller.changeModus('view'));
} else {
// Propose tool
Dialog.show({
......
......@@ -10,7 +10,9 @@ export default class EventItem {
}
view() {
if (!this.controller || !this.controller.data) return m(loadingScreen);
if (!this.controller || (!this.controller.data && this.controller.modus !== 'new')) {
return m(loadingScreen);
}
if (this.controller.modus !== 'view') return m(editEvent, { controller: this.controller });
return m(viewEvent, { controller: this.controller });
}
......
......@@ -81,7 +81,10 @@ export default class NewGroup extends EditView {
beforeSubmit() {
const { data } = this.form;
// exchange moderator object with string of id
this.submit({ ...data, moderator: data.moderator ? data.moderator._id : undefined });
this.submit({
...data,
moderator: data.moderator ? data.moderator._id : undefined,
}).then(() => this.controller.changeModus('view'));
}
view() {
......
......@@ -10,7 +10,9 @@ export default class GroupItem {
}
view() {
if (!this.controller || !this.controller.data) return m(loadingScreen);
if (!this.controller || (!this.controller.data && this.controller.modus !== 'new')) {
return m(loadingScreen);
}
if (this.controller.modus !== 'view') return m(editGroup, { controller: this.controller });
return m(viewGroup, { controller: this.controller });
}
......
......@@ -10,7 +10,7 @@ export default class ItemController {
this.modus = 'view';
} else {
this.modus = 'new';
this.data = {};
this.data = undefined;
}
this.handler = new ResourceHandler(resource, false);
this.embedded = embedded || {};
......@@ -26,7 +26,6 @@ export default class ItemController {
return new Promise((resolve, reject) => {
this.handler.post(data).then((response) => {
this.id = response._id;
this.changeModus('view');
resolve(response);
}).catch(reject);
});
......@@ -36,7 +35,6 @@ export default class ItemController {
return new Promise((resolve, reject) => {
this.handler.patch(data).then((response) => {
resolve(response);
this.changeModus('view');
}).catch(reject);
});
}
......
......@@ -22,7 +22,7 @@ export default class newJob extends EditView {
Object.keys(this.form.data).forEach((key) => {
submitData.append(key, this.form.data[key]);
});
this.submit(submitData);
this.submit(submitData).then(() => this.controller.changeModus('view'));
}
view() {
......
......@@ -10,7 +10,9 @@ export default class jobModal {
}
view() {
if (!this.controller || !this.controller.data) return m(loadingScreen);
if (!this.controller || (!this.controller.data && this.controller.modus !== 'new')) {
return m(loadingScreen);
}
if (this.controller.modus !== 'view') return m(editJob, { controller: this.controller });
return m(viewJob, { controller: this.controller });
}
......
......@@ -47,7 +47,7 @@ export default class editDoc extends EditView {
if (key !== 'files') submitData.append(key, this.form.data[key]);
});
files.forEach((file) => { submitData.append('files', file); });
this.submit(submitData);
this.submit(submitData).then(() => this.controller.changeModus('view'));
}
view() {
......
......@@ -10,7 +10,9 @@ export default class studydocItem {
}
view() {
if (!this.controller || !this.controller.data) return m(loadingScreen);
if (!this.controller || (!this.controller.data && this.controller.modus !== 'new')) {
return m(loadingScreen);
}
if (this.controller.modus !== 'view') return m(editDoc, { controller: this.controller });
return m(viewDoc, { controller: this.controller });
}
......
......@@ -14,7 +14,9 @@ export class UserItem {
}
view() {
if (!this.controller || !this.controller.data) return m(loadingScreen);
if (!this.controller || (!this.controller.data && this.controller.modus !== 'new')) {
return m(loadingScreen);
}
if (this.controller.modus !== 'view') return m(EditUser, { controller: this.controller });
return m(ViewUser, { controller: this.controller });
}
......
......@@ -86,7 +86,7 @@ export default class EditView extends ItemView {
beforeSubmit() {
if (Object.keys(this.form.data).length > 0) {
this.submit(this.form.data);
this.submit(this.form.data).then(() => this.controller.changeModus('view'));
} else {
this.controller.changeModus('view');
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment