-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Draft implementation of dictionary action and set and get value actions
- Loading branch information
1 parent
34cbe2d
commit 2a6e789
Showing
6 changed files
with
164 additions
and
2 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
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,85 @@ | ||
import {renderActionHeader, renderTable} from "~/render"; | ||
import {actions} from "~/actions"; | ||
import {renderValue} from "~/value"; | ||
|
||
interface DictionaryParameters { | ||
WFItems: WFItems | ||
} | ||
|
||
interface WFItems { | ||
Value: Value | ||
} | ||
|
||
interface Value { | ||
WFDictionaryFieldValueItems: DictionaryItem[] | ||
} | ||
|
||
interface DictionaryItem { | ||
WFKey: Object, | ||
WFItemType: Number, | ||
WFValue: WFValue, | ||
|
||
Key: Object, | ||
Type: Number, | ||
Value: WFValue, | ||
} | ||
|
||
interface WFValue { | ||
Value: Object, | ||
WFSerializationType: string | ||
} | ||
|
||
export default { | ||
title: 'Dictionary', | ||
color: 'white', | ||
background: '#fc880f', | ||
icon: 'book_fill', | ||
render: (container: HTMLElement, params: DictionaryParameters) => { | ||
const action = document.createElement('div'); | ||
const header = renderActionHeader(actions['dictionary']); | ||
action.appendChild(header); | ||
|
||
for (let item of params.WFItems.Value.WFDictionaryFieldValueItems) { | ||
item.Key = item.WFKey | ||
item.Type = item.WFItemType | ||
item.Value = item.WFValue | ||
// @ts-ignore | ||
delete item.WFKey; | ||
// @ts-ignore | ||
delete item.WFItemType; | ||
// @ts-ignore | ||
delete item.WFValue; | ||
} | ||
|
||
action.appendChild(renderTable(params.WFItems.Value.WFDictionaryFieldValueItems, function (key: any, value: any) { | ||
if (key === 'Type') { | ||
switch (value) { | ||
case 0: | ||
return 'Text'; | ||
case 3: | ||
return 'Number'; | ||
case 2: | ||
return 'Array'; | ||
case 1: | ||
return 'Dictionary'; | ||
case 4: | ||
return 'Boolean'; | ||
} | ||
} | ||
|
||
const valueElement = renderValue(value, key); | ||
valueElement.classList.add('sp-unstyled-value'); | ||
|
||
return valueElement; | ||
})); | ||
|
||
const br = document.createElement('br'); | ||
action.appendChild(br); | ||
|
||
return action; | ||
} | ||
} | ||
|
||
function dictToJSON() { | ||
|
||
} |
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,25 @@ | ||
import {renderValue} from "~/value"; | ||
import {renderActionHeader} from "~/render"; | ||
import {actions, actionText} from "~/actions"; | ||
|
||
interface GetDictionaryValueParameters { | ||
WFGetDictionaryValueType: string | ||
WFInput: string | object | ||
WFDictionaryKey: string | object | ||
} | ||
|
||
export default { | ||
title: 'Get', | ||
color: 'white', | ||
background: '#fc880f', | ||
icon: 'book_fill', | ||
render: (container: HTMLElement, params: GetDictionaryValueParameters) => { | ||
let content: HTMLElement[] = [renderValue(params.WFGetDictionaryValueType)]; | ||
if (params.WFGetDictionaryValueType === 'Value') { | ||
content.push(actionText('for'), renderValue(params['WFDictionaryKey'], 'Key')); | ||
} | ||
content.push(actionText('in'), renderValue(params['WFInput'], 'Dictionary')) | ||
|
||
return renderActionHeader(actions['getvalueforkey'], ...content); | ||
} | ||
} |
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 @@ | ||
import {renderValue} from "~/value"; | ||
import {renderActionHeader} from "~/render"; | ||
import {actions} from "~/actions"; | ||
|
||
interface GetDictionaryParameters { | ||
WFInput: string | object | ||
} | ||
|
||
export default { | ||
title: 'Get dictionary from', | ||
color: 'white', | ||
background: '#fc880f', | ||
icon: 'book_fill', | ||
render: (container: HTMLElement, params: GetDictionaryParameters) => { | ||
return renderActionHeader(actions['detect.dictionary'], | ||
renderValue(params['WFInput'], 'Input'), | ||
); | ||
} | ||
} |
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,25 @@ | ||
import {renderValue} from "~/value"; | ||
import {renderActionHeader} from "~/render"; | ||
import {actions, actionText} from "~/actions"; | ||
|
||
interface SetDictionaryValueParameters { | ||
WFInput: string | object | ||
WFDictionaryKey: string | object | ||
WFGetDictionaryValueType: string | object | ||
} | ||
|
||
export default { | ||
title: 'Set', | ||
color: 'white', | ||
background: '#fc880f', | ||
icon: 'book_fill', | ||
render: (container: HTMLElement, params: SetDictionaryValueParameters) => { | ||
return renderActionHeader(actions['setvalueforkey'], | ||
renderValue(params['WFInput'], 'Key'), | ||
actionText('to'), | ||
renderValue(params['WFGetDictionaryValueType'], 'Value'), | ||
actionText('in'), | ||
renderValue(params['WFInput'], 'Dictionary'), | ||
); | ||
} | ||
} |
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