Skip to content

Commit

Permalink
fixed for multi-nested
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Mar 17, 2023
1 parent 502d76c commit 8cb04d8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 27 deletions.
45 changes: 18 additions & 27 deletions src/webfrontend/EditorFieldVisibility.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class EditorFieldVisibility extends CustomMaskSplitter
resultList.push key
return resultList

__getFlatListOfAffectedSplitterFields: (optsData, prefix = '') ->
__getFlatListOfAffectedSplitterFields: (optsData, prefix = '', splitterFieldNames) ->
fieldList = []

fieldnames = []
Expand Down Expand Up @@ -68,21 +68,12 @@ class EditorFieldVisibility extends CustomMaskSplitter
fieldName = cleanedFieldName
fieldName = @objecttype + '.' + fieldName
#console.warn "fieldName", fieldName
if @splitterFieldNames.indexOf(fieldName) != -1
if splitterFieldNames.indexOf(fieldName) != -1
#console.log "PUSH 1111: " + fieldName
fieldList.push 'name' : fieldName, 'field' : field, 'element' : field.getElement()
# it is the block and not a field
else
# Es muss aber trotzdem irgendwie in splitterFieldNames vorkommen!?!?
#console.log "PUSH 222"
#console.warn "optsData", optsData
#console.warn "@splitterFieldNames", @splitterFieldNames
#console.warn "@splitterFieldNames.indexOf(fieldName)", @splitterFieldNames.indexOf(fieldName)
#console.log "fieldName", fieldName
#console.log "fieldNameOriginal", fieldNameOriginal
#console.log "cleanedFieldName", cleanedFieldName
if @splitterFieldNames.includes(fieldName)
fieldList.push 'name' : fieldName, 'field' : field, 'element' : field.getElement(), 'type' : 'block'
fieldList.push 'name' : fieldName, 'field' : field, 'element' : field.getElement(), 'type' : 'block'

#########################################
# NESTED
Expand All @@ -94,7 +85,7 @@ class EditorFieldVisibility extends CustomMaskSplitter
newPrefix = prefix + '.' + cleanedFieldName
else
newPrefix = cleanedFieldName
fields = @__getFlatListOfAffectedSplitterFields(fieldEntry, newPrefix)
fields = @__getFlatListOfAffectedSplitterFields(fieldEntry, newPrefix, splitterFieldNames)
fieldList = fieldList.concat fields

#########################################
Expand All @@ -113,7 +104,7 @@ class EditorFieldVisibility extends CustomMaskSplitter
fieldName = fieldName.replace(/_nested:/g, '')
fieldNameParts = fieldName.split('.')
lastPartOfFieldName = fieldNameParts.pop()
if @splitterFieldNames.indexOf(fieldName) != -1
if splitterFieldNames.indexOf(fieldName) != -1
fieldType = field._field.ColumnSchema.type
if fieldType.indexOf('custom-data-type') > 0
isCustomType = true
Expand Down Expand Up @@ -141,7 +132,7 @@ class EditorFieldVisibility extends CustomMaskSplitter
# actual _objecttype
@objecttype = opts.top_level_data?._objecttype

@splitterFieldNames = []
splitterFieldNames = []

# get inner fields
innerFields = @renderInnerFields(opts)
Expand Down Expand Up @@ -172,17 +163,17 @@ class EditorFieldVisibility extends CustomMaskSplitter

#console.log "innerSplitterFields", innerSplitterFields

@splitterFieldNames = @__getListOfFieldNamesInsideSplitter(innerSplitterFields)
#console.warn "splitterFieldNames", @splitterFieldNames
splitterFieldNames = @__getListOfFieldNamesInsideSplitter(innerSplitterFields)
#console.warn "splitterFieldNames", splitterFieldNames

@splitterFieldNamesFlat = @__getFlatListOfAffectedSplitterFields(opts.data)
splitterFieldNamesFlat = @__getFlatListOfAffectedSplitterFields(opts.data, '', splitterFieldNames)

# DAS splitterFieldNamesFlat ist das gleiche wie actionsfields von unten?
# Dann müsste ich das unten in __manageVisibilitys nicht noch einmal machen!!!

#console.error "@splitterFieldNamesFlat", @splitterFieldNamesFlat
#console.error "splitterFieldNamesFlat", splitterFieldNamesFlat

for splitterField in @splitterFieldNamesFlat
for splitterField in splitterFieldNamesFlat
if splitterField.name == observedFieldName
# get type of observed field
columnType = splitterField.type
Expand All @@ -195,14 +186,14 @@ class EditorFieldVisibility extends CustomMaskSplitter
type: ["data-changed"]
node: innerFields[0]
call: (ev, info) =>
@__manageVisibilitys(opts, columnType, observedField, jsonMap, observedFieldName)
@__manageVisibilitys(opts, columnType, observedField, jsonMap, observedFieldName, splitterFieldNamesFlat)

CUI.Events.listen
type: ["editor-changed"]
call: (ev, info) =>
@__manageVisibilitys(opts, columnType, observedField, jsonMap, observedFieldName)
@__manageVisibilitys(opts, columnType, observedField, jsonMap, observedFieldName, splitterFieldNamesFlat)

@__manageVisibilitys(opts, columnType, observedField, jsonMap, observedFieldName)
@__manageVisibilitys(opts, columnType, observedField, jsonMap, observedFieldName, splitterFieldNamesFlat)

div = CUI.dom.element("div", class: "fylr-editor-field-visibility")
if @getDataOptions()?.debugwithborder
Expand All @@ -215,18 +206,18 @@ class EditorFieldVisibility extends CustomMaskSplitter
# show or hide fields, depending on jsonMap and oberservedfield-value
##########################################################################################

__manageVisibilitys: (opts, columnType, observedField, jsonMap, observedFieldName) ->
__manageVisibilitys: (opts, columnType, observedField, jsonMap, observedFieldName, actionFields) ->
#console.log "f: __manageVisibilitys"
that = @

# get Value from observed field
observedFieldValue = ''

# make a list of field's names, which are in the splitter and may be shown or hidden
actionFields = []
#actionFields = []
#console.error "opts.data", opts.data
#actionFields = @__getFlatListOfAffectedSplitterFields(opts.data)
actionFields = @splitterFieldNamesFlat
#actionFields = @__getFlatListOfAffectedSplitterFields(opts.data, '', splitterFieldNames)
#actionFields = splitterFieldNamesFlat

#########################################
# observedfield: if columnType == CustomDataTypeDANTE
Expand Down
Empty file modified src/webfrontend/css/EditorFieldVisibility.css
100644 → 100755
Empty file.

0 comments on commit 8cb04d8

Please sign in to comment.