aboutsummaryrefslogtreecommitdiff
path: root/internal/admin/static/objecteditor.js
diff options
context:
space:
mode:
Diffstat (limited to 'internal/admin/static/objecteditor.js')
-rw-r--r--internal/admin/static/objecteditor.js41
1 files changed, 18 insertions, 23 deletions
diff --git a/internal/admin/static/objecteditor.js b/internal/admin/static/objecteditor.js
index 9c5a279..1abccbf 100644
--- a/internal/admin/static/objecteditor.js
+++ b/internal/admin/static/objecteditor.js
@@ -86,21 +86,17 @@ var SECTIONS = [
]
},
{
- id: 'on_use', label: 'On Use', labelHint: '(what happens when you use items on this)', path: 'on_use', isArray: true, fullWidth: true, interactionStyle: true, interScope: 'inline',
+ id: 'on_use', label: 'On Use', labelHint: '(what happens when you use items on this)', path: 'on_use', isArray: true, fullWidth: true, interactionStyle: true,
detect: function(d) { return d.on_use && Array.isArray(d.on_use); },
fields: [
['item_id', 'Item ID', 'search', 'e.g. keycard (empty = bare use)', '', null, 'items'],
- ['condition', 'Condition', 'inter_cond'],
- ['action', 'Action', 'inter_act'],
]
},
{
- id: 'on_look', label: 'On Look', labelHint: '(what happens when you "look <this>")', path: 'on_look', isArray: true, fullWidth: true, interactionStyle: true, interScope: 'inline',
+ id: 'on_look', label: 'On Look', labelHint: '(what happens when you "look <this>")', path: 'on_look', isArray: true, fullWidth: true, interactionStyle: true,
detect: function(d) { return d.on_look && Array.isArray(d.on_look); },
fields: [
['item_id', 'Item ID', 'search', '(optional — only fires if you carry this item)', '', null, 'items'],
- ['condition', 'Condition', 'inter_cond'],
- ['action', 'Action', 'inter_act'],
]
},
];
@@ -517,8 +513,6 @@ function renderArraySection(sec, data) {
showRemove: function(idx) { return 'removeArrayItem(\'' + sec.id + '\',' + idx + ')'; },
showField: function(secId, idx, key) { return 'showInterField(\'' + secId + '\',' + idx + ',\'' + key + '\')'; },
hideField: function(secId, idx, key) { return 'hideInterField(\'' + secId + '\',' + idx + ',\'' + key + '\')'; },
- addCondition: function(secId, idx) { return 'addInterRootCondition(\'' + secId + '\',' + idx + ')'; },
- addEffect: function(secId, idx) { return 'addInterAction(\'' + secId + '\',' + idx + ')'; },
renderField: function(sec, f, data, idx, optStyle) { return renderField(sec, f, data, idx, null, optStyle); },
onAdd: function() { return 'addArrayItem(\'' + sec.id + '\')'; },
});
@@ -822,10 +816,15 @@ function addArrayItem(cardID) {
var sec = SECTIONS.find(function(s) { return s.id === cardID; });
if (!sec || !sec.isArray) return;
var arr = objectData[sec.path] || [];
- var empty = {};
- sec.fields.forEach(function(f) {
- empty[f[0]] = f[2] === 'checkbox' ? false : (f[2] === 'number' ? 0 : '');
- });
+ var empty;
+ if (sec.interactionStyle) {
+ empty = {steps: []};
+ } else {
+ empty = {};
+ sec.fields.forEach(function(f) {
+ empty[f[0]] = f[2] === 'checkbox' ? false : (f[2] === 'number' ? 0 : '');
+ });
+ }
arr.push(empty);
objectData[sec.path] = arr;
renderCurrent();
@@ -915,13 +914,7 @@ function showInterField(secId, idx, key) {
function addInterRootCondition(secId, idx) {
var sec = SECTIONS.find(function(s) { return s.id === secId; });
if (!sec) return;
- ie_addRootConditionGroup(sec.path, idx);
-}
-
-function addInterAction(secId, idx) {
- var sec = SECTIONS.find(function(s) { return s.id === secId; });
- if (!sec) return;
- ie_addEffectToInteraction(sec.path, idx);
+ ie_addRootConditionGroup(sec.path, idx, 'entry');
}
function hideInterField(secId, idx, key) {
@@ -932,8 +925,8 @@ function hideInterField(secId, idx, key) {
ced_syncDOMToData(objectData);
ie_syncAllInteractions(objectData, SECTIONS);
if (objectData[secPath] && objectData[secPath][idx]) {
- if (key === 'condition' || key === 'action') {
- delete objectData[secPath][idx][key];
+ if (key === 'condition') {
+ delete objectData[secPath][idx].condition;
} else {
objectData[secPath][idx][key] = '';
}
@@ -1030,8 +1023,10 @@ function saveObject() {
var cleanedCond = ie_cleanCondition(dataItem.condition);
if (cleanedCond) item.condition = cleanedCond;
}
- if (dataItem.action && typeof dataItem.action === 'object') {
- item.action = dataItem.action;
+ if (dataItem.lock) item.lock = true;
+ if (dataItem.steps && Array.isArray(dataItem.steps)) {
+ var cleanedSteps = dataItem.steps.map(ie_cleanStep).filter(function(s) { return Object.keys(s).length > 0; });
+ if (cleanedSteps.length > 0) item.steps = cleanedSteps;
}
}
if (Object.keys(item).length > 0) arr.push(item);