@@ -161,10 +161,37 @@ class CustomDataTypeIconclass extends CustomDataTypeWithCommons
161
161
activeFrontendLanguage = that .getFrontendLanguage ()
162
162
163
163
searchUrl = ' https://iconclass.org/api/search?q=' + encodeURIComponent (input_searchstring) + ' &lang=' + activeFrontendLanguage + ' &size=999&page=1&sort=rank&keys=0' ;
164
+ ###
165
+ result is like
166
+ {
167
+ "result": [
168
+ "11H(JULIAN)131",
169
+ "11H(JULIAN)13",
170
+ "11H(JULIAN)119",
171
+ "11H(JULIAN)84",...
172
+ ],
173
+ "total": 148
174
+ }
175
+ ###
164
176
165
177
if searchStringIsNotation
166
178
searchUrl = ' https://iconclass.org/' + encodeURIComponent (input_searchstring) + ' .json'
167
179
180
+ ###
181
+ result is like
182
+ {
183
+ "n": "11H(JULIAN)2",
184
+ "p": [
185
+ "1",
186
+ "11",
187
+ "11H",
188
+ "11H(...)",
189
+ "11H(JULIAN)",
190
+ "11H(JULIAN)2"
191
+ ],
192
+ "b": "11H(JULIAN)2",
193
+ ###
194
+
168
195
# start request
169
196
searchsuggest_xhr .xhr = new (CUI .XHR )(url : searchUrl)
170
197
searchsuggest_xhr .xhr .start ().done ((data , status , statusText ) ->
@@ -216,34 +243,81 @@ class CustomDataTypeIconclass extends CustomDataTypeWithCommons
216
243
onClick : (ev2 , btn ) ->
217
244
iconclassInfo = btn .getOpt (" value" )
218
245
# ##############################################
219
- # brackets with dots provided?
246
+ # if search string is a notation
220
247
# ##############################################
221
- if iconclassInfo ? .n
222
- if iconclassInfo .n .includes ' (...)'
223
- # open popup and force user to input bracketsvalue
224
- # Example: 25G4(...)
225
- chosenTempUri = ' https://iconclass.org/' + iconclassInfo .n
226
- CUI .prompt (text : $$ (' custom.data.type.iconclass.modal.form.popup.brackets.select' ) + " " + chosenTempUri + " \n\n " + $$ (' custom.data.type.iconclass.modal.form.popup.brackets.choose' ), " 1" )
227
- .done (input) =>
228
- inputUpperCase = input .toUpperCase ()
229
- inputLowerCase = input .toLowerCase ()
230
-
231
- # replace in notation
232
- iconclassInfo .n = iconclassInfo .n .replace (' (...)' , " (" + inputUpperCase + " )" )
233
- # replace in labels
234
- for iconclassLabelKey, iconclassLabelValue of iconclassInfo .txt
235
- newLabel = iconclassLabelValue
236
- newLabel = newLabel .replace (" (mit NAMEN)" , ' : ' + inputLowerCase)
237
- newLabel = newLabel .replace (" (with NAME)" , ' : ' + inputLowerCase)
238
- newLabel = newLabel .replace (" (avec NOM)" , ' : ' + inputLowerCase)
239
- newLabel = newLabel .replace (" (col NOME)" , ' : ' + inputLowerCase)
240
- newLabel = newLabel .replace (" (NIMEN kanssa)" , ' : ' + inputLowerCase)
241
- iconclassInfo .txt [iconclassLabelKey] = newLabel
242
-
248
+ if searchStringIsNotation
249
+ if iconclassInfo ? .n
250
+ # ##############################################
251
+ # brackets with dots provided?
252
+ # ##############################################
253
+ if iconclassInfo .n .includes ' (...)'
254
+ # open popup and force user to input bracketsvalue
255
+ # Example: 25G4(...)
256
+ chosenTempUri = ' https://iconclass.org/' + iconclassInfo .n
257
+ CUI .prompt (text : $$ (' custom.data.type.iconclass.modal.form.popup.brackets.select' ) + " " + chosenTempUri + " \n\n " + $$ (' custom.data.type.iconclass.modal.form.popup.brackets.choose' ), " 1" )
258
+ .done (input) =>
259
+ inputUpperCase = input .toUpperCase ()
260
+ inputLowerCase = input .toLowerCase ()
261
+
262
+ # replace in notation
263
+ iconclassInfo .n = iconclassInfo .n .replace (' (...)' , " (" + inputUpperCase + " )" )
264
+ # replace in labels
265
+ for iconclassLabelKey, iconclassLabelValue of iconclassInfo .txt
266
+ newLabel = iconclassLabelValue
267
+ newLabel = newLabel .replace (" (mit NAMEN)" , ' : ' + inputLowerCase)
268
+ newLabel = newLabel .replace (" (with NAME)" , ' : ' + inputLowerCase)
269
+ newLabel = newLabel .replace (" (avec NOM)" , ' : ' + inputLowerCase)
270
+ newLabel = newLabel .replace (" (col NOME)" , ' : ' + inputLowerCase)
271
+ newLabel = newLabel .replace (" (NIMEN kanssa)" , ' : ' + inputLowerCase)
272
+ iconclassInfo .txt [iconclassLabelKey] = newLabel
273
+
274
+ # lock conceptURI in savedata
275
+ cdata .conceptURI = ' https://iconclass.org/' + iconclassInfo .n
276
+ cdata .frontendLanguage = activeFrontendLanguage
277
+
278
+ # lock conceptName in savedata
279
+ cdata .conceptName = IconclassUtil .getConceptNameFromObject iconclassInfo, cdata
280
+
281
+ cdata .conceptAncestors = []
282
+ # if treeview, add ancestors
283
+ if iconclassInfo ? .p ? .length > 0
284
+ # save ancestor-uris to cdata
285
+ for ancestor in iconclassInfo .p
286
+ cdata .conceptAncestors .push ' https://iconclass.org/' + ancestor
287
+ # add own uri to ancestor-uris
288
+ cdata .conceptAncestors .push ' https://iconclass.org/' + iconclassInfo .n
289
+
290
+ cdata .conceptAncestors = cdata .conceptAncestors .join (' ' )
291
+
292
+ # facetTerm
293
+ cdata .facetTerm = IconclassUtil .getFacetTerm (iconclassInfo, that .getDatabaseLanguages ())
294
+
295
+ # lock conceptFulltext in savedata
296
+ cdata ._fulltext = IconclassUtil .getFullTextFromObject iconclassInfo, false
297
+ # lock standard in savedata
298
+ cdata ._standard = IconclassUtil .getStandardTextFromObject that, iconclassInfo, cdata, false
299
+
300
+ # update the layout in form
301
+ that .__updateResult (cdata, layout, opts)
302
+ @
303
+ .fail =>
304
+ cdata = {}
305
+ that .__updateResult (cdata, layout, opts)
306
+ @
307
+ # ##############################################
308
+ # if no bracketsvalue in chosen record
309
+ # ##############################################
310
+ else
243
311
# lock conceptURI in savedata
244
- cdata .conceptURI = ' https://iconclass.org/' + iconclassInfo .n
312
+ if iconclassInfo ? .n
313
+ cdata .conceptURI = ' https://iconclass.org/' + iconclassInfo .n
314
+ else
315
+ cdata .conceptURI = ' https://iconclass.org/' + iconclassInfo
316
+
245
317
cdata .frontendLanguage = activeFrontendLanguage
246
318
319
+ fullInfoUrl = ' https://iconclass.org/' + iconclassInfo + ' .json'
320
+
247
321
# lock conceptName in savedata
248
322
cdata .conceptName = IconclassUtil .getConceptNameFromObject iconclassInfo, cdata
249
323
@@ -266,51 +340,48 @@ class CustomDataTypeIconclass extends CustomDataTypeWithCommons
266
340
# lock standard in savedata
267
341
cdata ._standard = IconclassUtil .getStandardTextFromObject that, iconclassInfo, cdata, false
268
342
269
- # update the layout in form
270
- that .__updateResult (cdata, layout, opts)
271
- @
272
- .fail =>
273
- cdata = {}
274
343
that .__updateResult (cdata, layout, opts)
275
344
@
276
- # ##############################################
277
- # if no bracketsvalue in chosen record
278
- # ##############################################
279
- else
345
+ # ##############################################
346
+ # if search string is NOT a notation
347
+ # ##############################################
348
+ else if ! searchStringIsNotation
349
+ # get full data from iconclass
350
+
351
+ fullInfoUrl = ' https://iconclass.org/' + iconclassInfo + ' .json'
352
+ # start request
353
+ searchsuggest_xhr .xhr = new (CUI .XHR )(url : fullInfoUrl)
354
+ searchsuggest_xhr .xhr .start ().done ((data , status , statusText ) ->
280
355
# lock conceptURI in savedata
281
- if iconclassInfo ? .n
282
- cdata .conceptURI = ' https://iconclass.org/' + iconclassInfo .n
283
- else
284
- cdata .conceptURI = ' https://iconclass.org/' + iconclassInfo
285
-
356
+ cdata .conceptURI = ' https://iconclass.org/' + iconclassInfo
286
357
cdata .frontendLanguage = activeFrontendLanguage
287
358
288
- fullInfoUrl = ' https://iconclass.org/' + iconclassInfo + ' .json'
289
-
290
359
# lock conceptName in savedata
291
- cdata .conceptName = IconclassUtil .getConceptNameFromObject iconclassInfo , cdata
360
+ cdata .conceptName = IconclassUtil .getConceptNameFromObject data , cdata
292
361
293
362
cdata .conceptAncestors = []
294
363
# if treeview, add ancestors
295
- if iconclassInfo ? .p ? .length > 0
364
+ if data ? .p ? .length > 0
296
365
# save ancestor-uris to cdata
297
- for ancestor in iconclassInfo .p
366
+ for ancestor in data .p
298
367
cdata .conceptAncestors .push ' https://iconclass.org/' + ancestor
299
368
# add own uri to ancestor-uris
300
- cdata .conceptAncestors .push ' https://iconclass.org/' + iconclassInfo . n
369
+ cdata .conceptAncestors .push ' https://iconclass.org/' + iconclassInfo
301
370
302
371
cdata .conceptAncestors = cdata .conceptAncestors .join (' ' )
303
372
304
373
# facetTerm
305
- cdata .facetTerm = IconclassUtil .getFacetTerm (iconclassInfo , that .getDatabaseLanguages ())
374
+ cdata .facetTerm = IconclassUtil .getFacetTerm (data , that .getDatabaseLanguages ())
306
375
307
376
# lock conceptFulltext in savedata
308
- cdata ._fulltext = IconclassUtil .getFullTextFromObject iconclassInfo , false
377
+ cdata ._fulltext = IconclassUtil .getFullTextFromObject data , false
309
378
# lock standard in savedata
310
- cdata ._standard = IconclassUtil .getStandardTextFromObject that, iconclassInfo , cdata, false
379
+ cdata ._standard = IconclassUtil .getStandardTextFromObject that, data , cdata, false
311
380
312
381
that .__updateResult (cdata, layout, opts)
313
382
@
383
+ )
384
+
314
385
items : menu_items
315
386
316
387
# if no suggestions: set "empty" message to menu
0 commit comments