From 4325e1591c80679309ba5697f85aefd508fb32f6 Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 17 Aug 2015 17:43:05 +0300 Subject: [PATCH] return to list and edit attributes fix --- frontend/client/src/controllers/record.js | 28 ++++++++++++---------- frontend/client/src/views/detail.js | 2 +- frontend/client/src/views/edit.js | 2 +- frontend/client/src/views/record/base.js | 4 ++++ frontend/client/src/views/record/detail.js | 4 ++++ 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/frontend/client/src/controllers/record.js b/frontend/client/src/controllers/record.js index b858cbadf8..34eaada56e 100644 --- a/frontend/client/src/controllers/record.js +++ b/frontend/client/src/controllers/record.js @@ -121,16 +121,19 @@ Espo.define('controllers/record', 'controller', function (Dep) { if (options.relate) { model.setRelate(options.relate); } - if (options.attributes) { - model.set(options.attributes) - } - this.main(this.getViewName('edit'), { + var o = { scope: this.name, model: model, returnUrl: options.returnUrl, views: this.getViews('edit'), - }); + }; + + if (options.attributes) { + this.model.set(options.attributes); + } + + this.main(this.getViewName('edit'), o); }); }, @@ -146,17 +149,18 @@ Espo.define('controllers/record', 'controller', function (Dep) { this.showLoadingNotification(); model.once('sync', function () { - - if (options.attributes) { - model.set(options.attributes) - } - - this.main(this.getViewName('edit'), { + var o = { scope: this.name, model: model, returnUrl: options.returnUrl, views: this.getViews('edit'), - }); + }; + + if (options.attributes) { + o.attributes = options.attributes; + } + + this.main(this.getViewName('edit'), o); }, this); model.fetch({main: true}); }); diff --git a/frontend/client/src/views/detail.js b/frontend/client/src/views/detail.js index 3400837a37..15c0b04cfe 100644 --- a/frontend/client/src/views/detail.js +++ b/frontend/client/src/views/detail.js @@ -31,7 +31,7 @@ Espo.define('views/detail', 'views/main', function (Dep) { name: 'Detail', - optionsToPass: [], + optionsToPass: ['attributes'], views: { header: { diff --git a/frontend/client/src/views/edit.js b/frontend/client/src/views/edit.js index 92523e503b..5fcfa52337 100644 --- a/frontend/client/src/views/edit.js +++ b/frontend/client/src/views/edit.js @@ -33,7 +33,7 @@ Espo.define('views/edit', 'views/main', function (Dep) { menu: null, - optionsToPass: ['returnUrl'], + optionsToPass: ['returnUrl', 'attributes'], views: { header: { diff --git a/frontend/client/src/views/record/base.js b/frontend/client/src/views/record/base.js index fe5005547b..a1c47e808e 100644 --- a/frontend/client/src/views/record/base.js +++ b/frontend/client/src/views/record/base.js @@ -131,6 +131,10 @@ Espo.define('Views.Record.Base', 'View', function (Dep) { this.attributes = this.model.getClonedAttributes(); + if (this.options.attributes) { + this.model.set(this.options.attributes); + } + this._initDependancy(); }, diff --git a/frontend/client/src/views/record/detail.js b/frontend/client/src/views/record/detail.js index 0ae562ab22..784e0a62a2 100644 --- a/frontend/client/src/views/record/detail.js +++ b/frontend/client/src/views/record/detail.js @@ -400,6 +400,10 @@ Espo.define('Views.Record.Detail', 'Views.Record.Base', function (Dep) { this.attributes = this.model.getClonedAttributes(); + if (this.options.attributes) { + this.model.set(this.options.attributes); + } + this.build(); this.listenTo(this.model, 'sync', function () { this.attributes = this.model.getClonedAttributes();