-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move revision settings to catalog (#1544)
* Move revision settings to catalog Added a package in core for catalog. Added settings panel for catalog. Updated registry entries for revisions to appear in catalog settings panel. Updated UI for registry settings card. * added key for i18n
- Loading branch information
1 parent
7a6e508
commit d9cf9df
Showing
9 changed files
with
128 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import "./templates/settings.html"; | ||
import "./templates/settings.js" |
19 changes: 19 additions & 0 deletions
19
imports/plugins/core/catalog/client/templates/settings.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<template name="catalogSettings"> | ||
{{#each reactionApps provides='catalogSettings'}} | ||
<div class="panel panel-default"> | ||
<div class="panel-heading panel-heading-flex"> | ||
<div class="panel-title"> | ||
<i class="fa fa-{{name}}"></i> | ||
<span data-i18n="{{i18nKeyLabel}}">{{label}}</span> | ||
|
||
</div> | ||
<div class="panel-controls"> | ||
<input class="checkbox-switch" type="checkbox" value={{name}} name="enabled" data-id="{{packageId}}" {{checked .}}> | ||
</div> | ||
</div> | ||
<div class="panel-body {{shown .}}"> | ||
{{> Template.dynamic template=template data=.}} | ||
</div> | ||
</div> | ||
{{/each}} | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Packages } from "/lib/collections"; | ||
|
||
Template.catalogSettings.helpers({ | ||
// | ||
// check if this package setting is enabled | ||
// | ||
checked(pkg) { | ||
let enabled; | ||
const pkgData = Packages.findOne(pkg.packageId); | ||
const setting = pkg.name.split("/").splice(-1); | ||
|
||
if (pkgData && pkgData.settings) { | ||
if (pkgData.settings[setting]) { | ||
enabled = pkgData.settings[setting].enabled; | ||
} | ||
} | ||
return enabled === true ? "checked" : ""; | ||
}, | ||
// | ||
// Template helper to add a hidden class if the condition is false | ||
// | ||
shown(pkg) { | ||
let enabled; | ||
const pkgData = Packages.findOne(pkg.packageId); | ||
const setting = pkg.name.split("/").splice(-1); | ||
|
||
if (pkgData && pkgData.settings) { | ||
if (pkgData.settings[setting]) { | ||
enabled = pkgData.settings[setting].enabled; | ||
} | ||
} | ||
|
||
return enabled !== true ? "hidden" : ""; | ||
} | ||
}); | ||
|
||
Template.catalogSettings.events({ | ||
/** | ||
* taxSettings settings update enabled status for tax service on change | ||
* @param {event} event jQuery Event | ||
* @return {void} | ||
*/ | ||
"change input[name=enabled]": (event) => { | ||
const name = event.target.value; | ||
const packageId = event.target.getAttribute("data-id"); | ||
const fields = [{ | ||
property: "enabled", | ||
value: event.target.checked | ||
}]; | ||
|
||
Meteor.call("registry/update", packageId, name, fields); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Reaction } from "/server/api"; | ||
|
||
Reaction.registerPackage({ | ||
label: "Catalog", | ||
name: "reaction-catalog", | ||
icon: "fa fa-archive", | ||
autoEnable: true, | ||
settings: { | ||
name: "Catalog" | ||
}, | ||
registry: [ | ||
{ | ||
provides: "dashboard", | ||
label: "Catalog", | ||
description: "Product catalog", | ||
icon: "fa fa-archive", | ||
priority: 2, | ||
container: "core" | ||
}, | ||
{ | ||
label: "Catalog Settings", | ||
name: "catalog/settings", | ||
provides: "settings", | ||
template: "catalogSettings" | ||
} | ||
] | ||
}); |
50 changes: 21 additions & 29 deletions
50
imports/plugins/core/revisions/client/components/settings.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters