@@ -53,20 +53,20 @@ class FindDublicateFieldValues extends CustomMaskSplitter
53
53
54
54
modal .autoSize ()
55
55
56
- _performSearchAndAdjustButton : (value , objecttype , fieldnameForSearch , infoButton ) ->
56
+ _performSearchAndAdjustButton : (value , objecttype , full_name , infoButton ) ->
57
57
url = window .easydb_server_url + ' /api/v1/search'
58
58
ez5 .api .search
59
59
type : " POST"
60
60
json_data :
61
61
limit : 100
62
- format : ' long '
62
+ format : ' standard '
63
63
generate_rights : false
64
64
objecttypes : [objecttype]
65
65
search : [
66
66
type : ' match' ,
67
67
mode : ' fulltext' ,
68
68
fields : [
69
- objecttype + ' . ' + fieldnameForSearch
69
+ full_name
70
70
],
71
71
string : value,
72
72
phrase : false ,
@@ -103,6 +103,10 @@ class FindDublicateFieldValues extends CustomMaskSplitter
103
103
if allowedGroups .includes group .id
104
104
isAllowedUse = true
105
105
106
+ # or if root-user
107
+ if ez5 .session .user .id == 1
108
+ isAllowedUse = true
109
+
106
110
# if use not allowed
107
111
if ! isAllowedUse
108
112
return CUI .dom .append (@ renderInnerFields (opts))
@@ -115,7 +119,12 @@ class FindDublicateFieldValues extends CustomMaskSplitter
115
119
innerFields = @ renderInnerFields (opts)
116
120
117
121
# 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
119
128
return innerFields
120
129
121
130
fieldsRendererPlain = @__customFieldsRenderer .fields [0 ]
@@ -124,7 +133,6 @@ class FindDublicateFieldValues extends CustomMaskSplitter
124
133
# ####################################################################################
125
134
# EDITOR-Mode
126
135
# ####################################################################################
127
-
128
136
if opts .mode == " editor" || opts .mode == " editor-bulk"
129
137
if fields
130
138
field = fields[0 ]
@@ -173,7 +181,7 @@ class FindDublicateFieldValues extends CustomMaskSplitter
173
181
if opts .data [field .ColumnSchema .name ]
174
182
# do search
175
183
fieldValue = opts .data [field .ColumnSchema .name ]
176
- @ ._performSearchAndAdjustButton (fieldValue, objecttype, field .ColumnSchema . name , infoButton)
184
+ @ ._performSearchAndAdjustButton (fieldValue, objecttype, field .__dbg_full_name , infoButton)
177
185
178
186
# listen for changes in field
179
187
CUI .Events .listen
@@ -184,7 +192,7 @@ class FindDublicateFieldValues extends CustomMaskSplitter
184
192
hasValue = false
185
193
if opts .data [field .ColumnSchema .name ]
186
194
fieldValue = opts .data [field .ColumnSchema .name ]
187
- @ ._performSearchAndAdjustButton (fieldValue, objecttype, field .ColumnSchema . name , infoButton)
195
+ @ ._performSearchAndAdjustButton (fieldValue, objecttype, field .__dbg_full_name , infoButton)
188
196
189
197
return CUI .dom .append (verticalLayout)
190
198
return
@@ -201,19 +209,68 @@ class FindDublicateFieldValues extends CustomMaskSplitter
201
209
return allowedGroups
202
210
203
211
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
+
204
235
getOptions : ->
205
236
that = @
206
237
# write the available fields from editor to select in maskconfig
207
238
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
208
250
if @opts ? .maskEditor
209
251
fields = @opts .maskEditor .opts .schema .fields
210
252
for field in fields
211
253
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
217
274
218
275
maskOptions = [
219
276
form :
0 commit comments