Skip to content

Commit

Permalink
Added changes that referes to latest changes proposed in the blending…
Browse files Browse the repository at this point in the history
… app to identify compositions by handler uris. Related issue: https://github.com/Starcounter/Blending/issues/422
  • Loading branch information
PatrykSzwer committed Apr 24, 2019
1 parent ea70498 commit 5660b5f
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions starcounter-include.html
Original file line number Diff line number Diff line change
Expand Up @@ -310,27 +310,34 @@
return this._renderCompositionChange(compositionProviderComposition, () => {
// convert string from view-model, to actual document fragment
const customComposition = this.stringToDocumentFragment(compositionProviderComposition);
var defaultViewHtmlsToBeRendered;

if (compositionProvider.ActualViewUris[0].hasOwnProperty("BlendingUri")) {
defaultViewHtmlsToBeRendered =
compositionProvider.ActualViewUris.filter(
x => !compositionProvider.ViewUris.includes(x.BlendingUri))
.map(x => x.ViewHtml);
} else {
defaultViewHtmlsToBeRendered = compositionProvider.ViewUris;
}

// append default compositions for views not covered by this composition
if (compositionProvider.ViewUris) {
const keys = Object.keys(this.viewModel);
for(let key of keys) {
const scoped = this.viewModel[key];
if (scoped && scoped.Html && compositionProvider.ViewUris.indexOf(scoped.Html) === -1) {
if (this.defaultComposition) {
this.template.scopedNodes.forEach((nodes) => {
if(nodes.scope === key) {
nodes.forEach((node) => appendComposition(customComposition, node));
}
});
}
else {
// BUG,TODO (tomalec): looks like a bug
// This means that if there *is* a custom composition, but it does not cover all views,
// and it happend that none of the views had a default composition,
// we would discard custom composition and use default -> fallback
return false;
}
const keys = Object.keys(this.viewModel);
for (let key of keys) {
const scoped = this.viewModel[key];
if (scoped && scoped.Html && defaultViewHtmlsToBeRendered.includes(scoped.Html)) {
if (this.defaultComposition) {
this.template.scopedNodes.forEach((nodes) => {
if (nodes.scope === key) {
nodes.forEach((node) => appendComposition(customComposition, node));
}
});
}
else {
// BUG,TODO (tomalec): looks like a bug
// This means that if there *is* a custom composition, but it does not cover all views,
// and it happend that none of the views had a default composition,
// we would discard custom composition and use default -> fallback
return false;
}
}
}
Expand Down

0 comments on commit 5660b5f

Please sign in to comment.