From 841923b79cb8106427aae5443b16c8bfda8ebcd5 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Mon, 22 Jun 2020 10:13:10 +1000 Subject: [PATCH] Create CW-version of site singleton --- assets/javascripts/wizard/initializers/custom.js.es6 | 2 +- assets/javascripts/wizard/models/site.js.es6 | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 assets/javascripts/wizard/models/site.js.es6 diff --git a/assets/javascripts/wizard/initializers/custom.js.es6 b/assets/javascripts/wizard/initializers/custom.js.es6 index af3d64eb..f5f7128f 100644 --- a/assets/javascripts/wizard/initializers/custom.js.es6 +++ b/assets/javascripts/wizard/initializers/custom.js.es6 @@ -23,7 +23,7 @@ export default { const Store = requirejs("discourse/models/store").default; const registerRawHelpers = requirejs("discourse-common/lib/raw-handlebars-helpers").registerRawHelpers; const RawHandlebars = requirejs("discourse-common/lib/raw-handlebars").default; - const Site = requirejs("discourse/models/site").default; + const Site = requirejs("discourse/plugins/discourse-custom-wizard/wizard/models/site").default; const RestAdapter = requirejs("discourse/adapters/rest").default; Discourse.Model = EmberObject.extend(); diff --git a/assets/javascripts/wizard/models/site.js.es6 b/assets/javascripts/wizard/models/site.js.es6 new file mode 100644 index 00000000..f3a7d1e5 --- /dev/null +++ b/assets/javascripts/wizard/models/site.js.es6 @@ -0,0 +1,10 @@ +import Site from "discourse/models/site"; + +export default Site.reopenClass({ + // There is no site data actually loaded by the CW yet. This placeholder is + // needed by imported classes + createCurrent() { + const store = Discourse.__container__.lookup("service:store"); + return store.createRecord("site", {}); + }, +}) \ No newline at end of file