Skip to content

Commit

Permalink
tidy variable parsing for parameter equals string feedback, refactor …
Browse files Browse the repository at this point in the history
…feedback styles, version bump
  • Loading branch information
phillipivan committed Sep 22, 2024
1 parent fbdc609 commit 00f27e2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 34 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "generic-emberplus",
"version": "2.4.1",
"version": "2.4.2",
"main": "dist/index.js",
"scripts": {
"prepare": "husky",
Expand Down
52 changes: 19 additions & 33 deletions src/feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ export enum FeedbackId {
TargetBackgroundSelected = 'targetBackgroundSelected',
}

const styles = {
blackOnWhite: {
bgcolor: combineRgb(255, 255, 255),
color: combineRgb(0, 0, 0),
},
blackOnRed: {
bgcolor: combineRgb(255, 0, 0),
color: combineRgb(0, 0, 0),
},
}

export function GetFeedbacksList(
_self: EmberPlusInstance, //InstanceBase<EmberPlusConfig>,
_emberClient: EmberClient,
Expand All @@ -26,10 +37,7 @@ export function GetFeedbacksList(
name: 'Parameter Equals',
description: 'Checks the current value of a paramter',
type: 'boolean',
defaultStyle: {
bgcolor: combineRgb(255, 255, 255),
color: combineRgb(0, 0, 0),
},
defaultStyle: styles.blackOnWhite,
options: [
{
type: 'dropdown',
Expand Down Expand Up @@ -61,10 +69,7 @@ export function GetFeedbacksList(
name: 'Parameter Equals String',
description: 'Checks the current value of a paramter against a String',
type: 'boolean',
defaultStyle: {
bgcolor: combineRgb(255, 255, 255),
color: combineRgb(0, 0, 0),
},
defaultStyle: styles.blackOnWhite,
options: [
{
type: 'dropdown',
Expand All @@ -84,11 +89,8 @@ export function GetFeedbacksList(
},
],
callback: async (feedback, context) => {
const path = await resolvePath(
_self,
await context.parseVariablesInString(feedback.options['path']?.toString() ?? ''),
)
const value: string = await context.parseVariablesInString(feedback.options['value']?.toString() ?? '')
const path = await resolvePath(context, feedback.options['path']?.toString() ?? '')
const value = await context.parseVariablesInString(feedback.options['value']?.toString() ?? '')
return state.parameters.get(path) == value
},
subscribe: async (feedback, context) => {
Expand All @@ -99,10 +101,7 @@ export function GetFeedbacksList(
name: 'Take is possible',
description: 'Shows if there is take possible',
type: 'boolean',
defaultStyle: {
bgcolor: combineRgb(255, 255, 255),
color: combineRgb(255, 0, 0),
},
defaultStyle: styles.blackOnWhite,
options: [],
callback: () => {
return state.selected.target != -1 && state.selected.source != -1 && state.selected.matrix != -1
Expand All @@ -112,10 +111,7 @@ export function GetFeedbacksList(
name: 'Clear is possible',
description: 'Changes when a selection is made.',
type: 'boolean',
defaultStyle: {
bgcolor: combineRgb(255, 255, 255),
color: combineRgb(255, 0, 0),
},
defaultStyle: styles.blackOnRed,
options: [],
callback: () => {
return state.selected.target != -1 || state.selected.source != -1 || state.selected.matrix != -1
Expand All @@ -125,12 +121,7 @@ export function GetFeedbacksList(
name: 'Source Background If Selected',
description: 'Change Background of Source, when it is currently selected.',
type: 'boolean',
defaultStyle: {
// The default style change for a boolean feedback
// The user will be able to customise these values as well as the fields that will be changed
bgcolor: combineRgb(255, 0, 0),
color: combineRgb(0, 0, 0),
},
defaultStyle: styles.blackOnRed,
options: [
{
type: 'number',
Expand Down Expand Up @@ -161,12 +152,7 @@ export function GetFeedbacksList(
name: 'Target Background if Selected',
description: 'Change Background of Target, when it is currently selected.',
type: 'boolean',
defaultStyle: {
// The default style change for a boolean feedback
// The user will be able to customise these values as well as the fields that will be changed
bgcolor: combineRgb(255, 0, 0),
color: combineRgb(0, 0, 0),
},
defaultStyle: styles.blackOnRed,
options: [
{
type: 'number',
Expand Down

0 comments on commit 00f27e2

Please sign in to comment.