Skip to content

Commit 3562b6c

Browse files
added 1 level linked-table
1 parent 9221eab commit 3562b6c

File tree

3 files changed

+75
-12
lines changed

3 files changed

+75
-12
lines changed

l10n/find-duplicate-field-values.csv

+2
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ server.config.parameter.system.FindDuplicateFieldvalues.find_duplicate_field_val
88
find.duplicate.field.values.fieldtotestforduplicates,Feld auswählen,Choose field
99
fylr-plugin-find-duplicate-field-values.info.link,Dubletten gefunden. Mehr Info hier,Duplicates found. More information
1010
fylr-plugin-find-duplicate-field-values.modal.open.link,Öffnen,Öffnen
11+
fylr-plugin-find-duplicate-field-values.options.empty,Ohne,Without
12+
fylr-plugin-find-duplicate-field-values.options.empty_save,Die Optionen werden erst nach dem Speichern sichtbar,The options only become visible after saving

src/webfrontend/css/find-duplicate-field-values.css

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.fylr-plugin-default-values-from-pool {
2+
grid-column: span 4;
3+
}
4+
15
/* the table, in which the found dublicate-values are displayed */
26
.dublicate-info-standard-display {
37
margin-right: 30px;

src/webfrontend/find-duplicate-field-values.coffee

+69-12
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,20 @@ class FindDublicateFieldValues extends CustomMaskSplitter
5353

5454
modal.autoSize()
5555

56-
_performSearchAndAdjustButton: (value, objecttype, fieldnameForSearch, infoButton) ->
56+
_performSearchAndAdjustButton: (value, objecttype, full_name, infoButton) ->
5757
url = window.easydb_server_url + '/api/v1/search'
5858
ez5.api.search
5959
type: "POST"
6060
json_data:
6161
limit: 100
62-
format: 'long'
62+
format: 'standard'
6363
generate_rights: false
6464
objecttypes: [objecttype]
6565
search: [
6666
type: 'match',
6767
mode: 'fulltext',
6868
fields: [
69-
objecttype + '.' + fieldnameForSearch
69+
full_name
7070
],
7171
string: value,
7272
phrase: false,
@@ -103,6 +103,10 @@ class FindDublicateFieldValues extends CustomMaskSplitter
103103
if allowedGroups.includes group.id
104104
isAllowedUse = true
105105

106+
# or if root-user
107+
if ez5.session.user.id == 1
108+
isAllowedUse = true
109+
106110
# if use not allowed
107111
if ! isAllowedUse
108112
return CUI.dom.append(@renderInnerFields(opts))
@@ -115,7 +119,12 @@ class FindDublicateFieldValues extends CustomMaskSplitter
115119
innerFields = @renderInnerFields(opts)
116120

117121
# no action in detail-mode
118-
if opts.mode == "detail"
122+
if opts.mode == 'detail' || opts.mode == 'expert'
123+
return innerFields
124+
125+
configuredField = @getDataOptions()?.fieldtotestforduplicates
126+
127+
if configuredField == null
119128
return innerFields
120129

121130
fieldsRendererPlain = @__customFieldsRenderer.fields[0]
@@ -124,7 +133,6 @@ class FindDublicateFieldValues extends CustomMaskSplitter
124133
#####################################################################################
125134
# EDITOR-Mode
126135
#####################################################################################
127-
128136
if opts.mode == "editor" || opts.mode == "editor-bulk"
129137
if fields
130138
field = fields[0]
@@ -173,7 +181,7 @@ class FindDublicateFieldValues extends CustomMaskSplitter
173181
if opts.data[field.ColumnSchema.name]
174182
# do search
175183
fieldValue = opts.data[field.ColumnSchema.name]
176-
@._performSearchAndAdjustButton(fieldValue, objecttype, field.ColumnSchema.name, infoButton)
184+
@._performSearchAndAdjustButton(fieldValue, objecttype, field.__dbg_full_name, infoButton)
177185

178186
# listen for changes in field
179187
CUI.Events.listen
@@ -184,7 +192,7 @@ class FindDublicateFieldValues extends CustomMaskSplitter
184192
hasValue = false
185193
if opts.data[field.ColumnSchema.name]
186194
fieldValue = opts.data[field.ColumnSchema.name]
187-
@._performSearchAndAdjustButton(fieldValue, objecttype, field.ColumnSchema.name, infoButton)
195+
@._performSearchAndAdjustButton(fieldValue, objecttype, field.__dbg_full_name, infoButton)
188196

189197
return CUI.dom.append(verticalLayout)
190198
return
@@ -201,19 +209,68 @@ class FindDublicateFieldValues extends CustomMaskSplitter
201209
return allowedGroups
202210

203211

212+
##########################################################################################
213+
# make Option out of linked-table
214+
##########################################################################################
215+
216+
__getOptionsFromLinkedTable: (linkedField, linkTableName)->
217+
newOptions = []
218+
for field in linkedField.mask.fields
219+
if field.kind == 'field'
220+
parts = field._full_name.split('.')
221+
objecttype = parts[0]
222+
nested = '_nested:' + parts[1]
223+
fieldName = parts[2]
224+
fieldSearchPath = objecttype + '.' + nested + '.' + fieldName
225+
newOption =
226+
value: fieldSearchPath
227+
test: fieldSearchPath
228+
newOptions.push newOption
229+
return newOptions
230+
231+
##########################################################################################
232+
# get Options from MaskSettings
233+
##########################################################################################
234+
204235
getOptions: ->
205236
that = @
206237
# write the available fields from editor to select in maskconfig
207238
fieldOptions = []
239+
240+
# leere Option
241+
emptyOption =
242+
value : null
243+
text : $$('fylr-plugin-find-duplicate-field-values.options.empty')
244+
245+
fieldOptions.push emptyOption
246+
247+
fieldsFound = false
248+
249+
# presents only level 0 and level 1 for the selection
208250
if @opts?.maskEditor
209251
fields = @opts.maskEditor.opts.schema.fields
210252
for field in fields
211253
if field.kind == 'field'
212-
if field._column.type == 'text_oneline'
213-
newOption =
214-
value : field._full_name
215-
text : field._column._name_localized + ' [' + field.column_name_hint + '] ("' + field._full_name + '")'
216-
fieldOptions.push newOption
254+
newOption =
255+
value : field._full_name
256+
text : field._full_name
257+
fieldOptions.push newOption
258+
fieldsFound = true
259+
if field.kind == 'linked-table'
260+
linkTableName = field.other_table_name_hint
261+
test = @__getOptionsFromLinkedTable(field, linkTableName)
262+
if test
263+
fieldsFound = true
264+
fieldOptions = fieldOptions.concat test
265+
266+
# show hint, if record was not saved yet
267+
if ! fieldsFound
268+
fieldOptions = []
269+
emptyOption =
270+
value : null
271+
text : $$('fylr-plugin-find-duplicate-field-values.options.empty_save')
272+
273+
fieldOptions.push emptyOption
217274

218275
maskOptions = [
219276
form:

0 commit comments

Comments
 (0)