Commit d4e64603fd143fd649746ace52baeea019fc7606

Authored by Katarzyna Krasnowska
1 parent 4d9921c9

added nesting to collapsed subform descriptions

entries/forms.py
... ... @@ -237,6 +237,10 @@ class FormFactory(object):
237 237 *components
238 238 ))
239 239  
  240 + @staticmethod
  241 + def additional_queries():
  242 + return []
  243 +
240 244 @classmethod
241 245 def get_form(cls, unique_number=None, *args, **kwargs):
242 246 unique_number = cls.unique_number() if unique_number is None else unique_number
... ... @@ -270,6 +274,11 @@ class FormFactory(object):
270 274  
271 275 form_class.__init__ = form_init
272 276  
  277 + def get_queries(self, negated_attrs):
  278 + return super(type(self), self).get_queries(negated_attrs) + cls.additional_queries()
  279 +
  280 + form_class.get_queries = get_queries
  281 +
273 282 form_class.base_fields[cls.unique_name('negated', unique_number)] = SwitchField(_('Zaneguj'), css_class='negate-switch')
274 283 for field_name, field_maker, layout_maker in cls.field_makers:
275 284 if field_name is not None:
... ... @@ -511,6 +520,10 @@ class LexFormFactory(FormFactory):
511 520 )
512 521  
513 522 @staticmethod
  523 + def additional_queries():
  524 + return [Q(('main_type__name', 'lex'))]
  525 +
  526 + @staticmethod
514 527 def get_child_form_prefix(child_form):
515 528 if child_form.model_class == PhraseType:
516 529 return 'id__in'
... ... @@ -627,7 +640,7 @@ class PredefinedPreferenceFormFactory(FormFactory):
627 640 (
628 641 'predefined',
629 642 lambda: ModelMultipleChoiceFilter(
630   - label='Predefiniowane',
  643 + label=_('Predefiniowane'),
631 644 queryset=PredefinedSelectionalPreference.objects.all(),
632 645 key='key',
633 646 lookup='key',
... ...
entries/static/entries/css/entries.css
... ... @@ -140,11 +140,11 @@ legend {
140 140 }
141 141  
142 142 .to-remove {
143   - background-color: #f6ce95;
  143 + background-color: #f0b9b8;
144 144 }
145 145  
146 146 .to-collapse {
147   - background-color: white;
  147 + background-color: #fae4c4;
148 148 }
149 149  
150 150 .collapsed-info {
... ... @@ -157,7 +157,7 @@ legend {
157 157 }
158 158  
159 159 .negated2 {
160   - background-color: #f48484;
  160 + background-color: #de6764;
161 161 }
162 162  
163 163 .form-group {
... ...
entries/static/entries/js/forms.js
... ... @@ -91,7 +91,7 @@ function collapsed_subform_desc(element) {
91 91 } else if (tag === 'form') {
92 92 var attributes = [];
93 93 element.children('fieldset').children('.form-group.row').children('label').each(function() {
94   - var attr = collapsed_subform_desc($(this), false);
  94 + var attr = collapsed_subform_desc($(this));
95 95 if (attr) {
96 96 attributes.push(attr);
97 97 }
... ... @@ -99,6 +99,28 @@ function collapsed_subform_desc(element) {
99 99 if (attributes.length > 0) {
100 100 ret += attributes.join(', ');
101 101 }
  102 + element.children('fieldset').children('.and-or-forms').each(function() {
  103 + var elems = [];
  104 + $(this).children().each(function() {
  105 + var child = $(this);
  106 + var child_tag = child.tagName();
  107 + var elem = '';
  108 + if (child_tag === 'form') {
  109 + if (child.hasClass('negated')) {
  110 + elem += gettext('nie') + ' ';
  111 + }
  112 + elem += '[' + child.children('fieldset').children('legend').immediateText().trim() + '] ' + collapsed_subform_desc(child);
  113 + } else if (child.hasClass('form-or') || child.hasClass('form-other')) {
  114 + elem = child.find('span').html();
  115 + }
  116 + if (elem) {
  117 + elems.push('<li>' + elem + '</li>');
  118 + }
  119 + });
  120 + if (elems.length > 0) {
  121 + ret += '<ul>' + elems.join('') + '</ul>';
  122 + }
  123 + });
102 124 return ret;
103 125 } else if (element.siblings('label').length > 0) {
104 126 return '';
... ...
locale/en/LC_MESSAGES/django.mo
No preview for this file type
locale/en/LC_MESSAGES/django.po
... ... @@ -8,7 +8,7 @@ msgid &quot;&quot;
8 8 msgstr ""
9 9 "Project-Id-Version: PACKAGE VERSION\n"
10 10 "Report-Msgid-Bugs-To: \n"
11   -"POT-Creation-Date: 2021-01-19 10:57+0100\n"
  11 +"POT-Creation-Date: 2021-01-19 13:57+0100\n"
12 12 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13 13 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14 14 "Language-Team: LANGUAGE <LL@li.org>\n"
... ... @@ -91,7 +91,7 @@ msgstr &quot;other units in the synset:&quot;
91 91 msgid "hiperonimy synsetu:"
92 92 msgstr "synset hypernyms:"
93 93  
94   -#: entries/form_fields/specialised_fields.py:44 entries/forms.py:509
  94 +#: entries/form_fields/specialised_fields.py:44 entries/forms.py:518
95 95 msgid "Typ frazeologizmu"
96 96 msgstr "Phraseologism type"
97 97  
... ... @@ -99,7 +99,7 @@ msgstr &quot;Phraseologism type&quot;
99 99 msgid "Typ frazy"
100 100 msgstr "Phrase type"
101 101  
102   -#: entries/form_fields/specialised_fields.py:51 entries/forms.py:593
  102 +#: entries/form_fields/specialised_fields.py:51 entries/forms.py:606
103 103 msgid "wybierz"
104 104 msgstr "choose"
105 105  
... ... @@ -155,9 +155,9 @@ msgstr &quot;Add&quot;
155 155 msgid "Schemat"
156 156 msgstr "Schema"
157 157  
158   -#: entries/forms.py:145 entries/forms.py:443 entries/forms.py:604
159   -#: entries/forms.py:723 entries/forms.py:725 entries/forms.py:727
160   -#: entries/forms.py:729
  158 +#: entries/forms.py:145 entries/forms.py:452 entries/forms.py:617
  159 +#: entries/forms.py:736 entries/forms.py:738 entries/forms.py:740
  160 +#: entries/forms.py:742
161 161 msgid "Fraza"
162 162 msgstr "Phrase"
163 163  
... ... @@ -185,8 +185,8 @@ msgstr &quot;Filter&quot;
185 185 msgid "Wyczyść"
186 186 msgstr "Reset"
187 187  
188   -#: entries/forms.py:166 entries/forms.py:459 entries/forms.py:465
189   -#: entries/forms.py:504 entries/templates/entries_list.html:6
  188 +#: entries/forms.py:166 entries/forms.py:468 entries/forms.py:474
  189 +#: entries/forms.py:513 entries/templates/entries_list.html:6
190 190 msgid "Lemat"
191 191 msgstr "Lemma"
192 192  
... ... @@ -222,177 +222,181 @@ msgstr &quot;Collapse&quot;
222 222 msgid "Usuń"
223 223 msgstr "Remove"
224 224  
225   -#: entries/forms.py:273 entries/forms.py:761
  225 +#: entries/forms.py:282 entries/forms.py:774
226 226 msgid "Zaneguj"
227 227 msgstr "Negate"
228 228  
229   -#: entries/forms.py:288
  229 +#: entries/forms.py:297
230 230 msgid "Schemat składniowy"
231 231 msgstr "Syntactic schema"
232 232  
233   -#: entries/forms.py:294
  233 +#: entries/forms.py:303
234 234 msgid "Opinia o schemacie"
235 235 msgstr "Schema opinion"
236 236  
237   -#: entries/forms.py:306
  237 +#: entries/forms.py:315
238 238 msgid "Typ"
239 239 msgstr "Type"
240 240  
241   -#: entries/forms.py:308
  241 +#: entries/forms.py:317
242 242 msgid "zwykły"
243 243 msgstr "ordinary"
244 244  
245   -#: entries/forms.py:309
  245 +#: entries/forms.py:318
246 246 msgid "frazeologiczny"
247 247 msgstr "phraseological"
248 248  
249   -#: entries/forms.py:318
  249 +#: entries/forms.py:327
250 250 msgid "Zwrotność"
251 251 msgstr "Reflexiveness"
252 252  
253   -#: entries/forms.py:376
  253 +#: entries/forms.py:385
254 254 msgid "Liczba pozycyj"
255 255 msgstr "Number of positions"
256 256  
257   -#: entries/forms.py:391 entries/forms.py:599
  257 +#: entries/forms.py:400 entries/forms.py:612
258 258 msgid "Pozycja"
259 259 msgstr "Position"
260 260  
261   -#: entries/forms.py:407
  261 +#: entries/forms.py:416
262 262 msgid "Pozycja składniowa"
263 263 msgstr "Syntactic position"
264 264  
265   -#: entries/forms.py:413
  265 +#: entries/forms.py:422
266 266 msgid "Funkcja gramatyczna"
267 267 msgstr "Grammatical function"
268 268  
269   -#: entries/forms.py:423
  269 +#: entries/forms.py:432
270 270 msgid "Kontrola"
271 271 msgstr "Control"
272 272  
273   -#: entries/forms.py:433
  273 +#: entries/forms.py:442
274 274 msgid "Kontrola predykatywna"
275 275 msgstr "Predicative control"
276 276  
277   -#: entries/forms.py:442
  277 +#: entries/forms.py:451
278 278 msgid "Typ frazy występujący na pozycji."
279 279 msgstr ""
280 280  
281   -#: entries/forms.py:479
  281 +#: entries/forms.py:488
282 282 msgid "Frazeologizm"
283 283 msgstr "Phraseologism"
284 284  
285   -#: entries/forms.py:485
  285 +#: entries/forms.py:494
286 286 msgid "Wybór lematów"
287 287 msgstr "Lemma choice"
288 288  
289   -#: entries/forms.py:495
  289 +#: entries/forms.py:504
290 290 msgid "Łączenie lematów"
291 291 msgstr "Lemma joining"
292 292  
293   -#: entries/forms.py:508 entries/forms.py:782
  293 +#: entries/forms.py:517 entries/forms.py:795
294 294 msgid "Typ składniowy frazeologizmu."
295 295 msgstr ""
296 296  
297   -#: entries/forms.py:527
  297 +#: entries/forms.py:540
298 298 msgid "Rama semantyczna"
299 299 msgstr "Semantic frame"
300 300  
301   -#: entries/forms.py:533 entries/templates/entry_display.html:33
  301 +#: entries/forms.py:546 entries/templates/entry_display.html:33
302 302 #: entries/templates/entry_display.html:50
303 303 #: entries/templates/entry_display.html:67
304 304 msgid "Opinia"
305 305 msgstr "Opinion"
306 306  
307   -#: entries/forms.py:543
  307 +#: entries/forms.py:556
308 308 msgid "Liczba argumentów"
309 309 msgstr "Number of arguments"
310 310  
311   -#: entries/forms.py:550
  311 +#: entries/forms.py:563
312 312 msgid "Liczba preferencyj selekcyjnych argumentu"
313 313 msgstr "Number of argument’s selectional preferences"
314 314  
315   -#: entries/forms.py:556
  315 +#: entries/forms.py:569
316 316 msgid "Argument"
317 317 msgstr "Argument"
318 318  
319   -#: entries/forms.py:572
  319 +#: entries/forms.py:585
320 320 msgid "Argument semantyczny"
321 321 msgstr "Semantic argument"
322 322  
323   -#: entries/forms.py:578
  323 +#: entries/forms.py:591
324 324 msgid "Rola"
325 325 msgstr "Role"
326 326  
327   -#: entries/forms.py:585
  327 +#: entries/forms.py:598
328 328 msgid "Atrybut roli"
329 329 msgstr "Role attribute"
330 330  
331   -#: entries/forms.py:592 entries/forms.py:595
  331 +#: entries/forms.py:605 entries/forms.py:608
332 332 msgid "Preferencja selekcyjna"
333 333 msgstr "Selectional preference"
334 334  
335   -#: entries/forms.py:593
  335 +#: entries/forms.py:606
336 336 msgid "Predefiniowana grupa znaczeń"
337 337 msgstr "Predefined meanings class"
338 338  
339   -#: entries/forms.py:593
  339 +#: entries/forms.py:606
340 340 msgid "Wyrażona przez relację"
341 341 msgstr "Expressed by relation"
342 342  
343   -#: entries/forms.py:593
  343 +#: entries/forms.py:606
344 344 msgid "Wyrażona przez jednostkę leksykalną Słowosieci"
345 345 msgstr "Expressed by plWordnet lexical unit"
346 346  
347   -#: entries/forms.py:603
  347 +#: entries/forms.py:616
348 348 msgid "Typ frazy, przez którą może być realizowany argument."
349 349 msgstr ""
350 350  
351   -#: entries/forms.py:624
  351 +#: entries/forms.py:637
352 352 msgid "Preferencja predefiniowana"
353 353 msgstr "Predefined preference"
354 354  
355   -#: entries/forms.py:644
  355 +#: entries/forms.py:643
  356 +msgid "Predefiniowane"
  357 +msgstr "Predefined"
  358 +
  359 +#: entries/forms.py:657
356 360 msgid "Preferencja – relacja"
357 361 msgstr "Relational preference"
358 362  
359   -#: entries/forms.py:650
  363 +#: entries/forms.py:663
360 364 msgid "Relacja"
361 365 msgstr "Relation"
362 366  
363   -#: entries/forms.py:661
  367 +#: entries/forms.py:674
364 368 msgid "Do: rola"
365 369 msgstr "To: role"
366 370  
367   -#: entries/forms.py:668
  371 +#: entries/forms.py:681
368 372 msgid "Do: atrybut"
369 373 msgstr "To: attribute"
370 374  
371   -#: entries/forms.py:680
  375 +#: entries/forms.py:693
372 376 msgid "Preferencja – Słowosieć"
373 377 msgstr "plWordnet preference"
374 378  
375   -#: entries/forms.py:686
  379 +#: entries/forms.py:699
376 380 msgid "Jednostka leksykalna"
377 381 msgstr "Lexical unit"
378 382  
379   -#: entries/forms.py:734
  383 +#: entries/forms.py:747
380 384 msgid "Fraza {}"
381 385 msgstr "{} phrase"
382 386  
383   -#: entries/forms.py:736 entries/polish_strings.py:125
  387 +#: entries/forms.py:749 entries/polish_strings.py:125
384 388 msgid "frazeologizm"
385 389 msgstr "phraseologism"
386 390  
387   -#: entries/forms.py:772
  391 +#: entries/forms.py:785
388 392 msgid "Realizacja składniowa frazy."
389 393 msgstr ""
390 394  
391   -#: entries/forms.py:776
  395 +#: entries/forms.py:789
392 396 msgid "Fraza składowa frazeologizmu porównawczego."
393 397 msgstr ""
394 398  
395   -#: entries/forms.py:778
  399 +#: entries/forms.py:791
396 400 msgid "Fraza realizująca frazeologizm."
397 401 msgstr ""
398 402  
... ...
locale/en/LC_MESSAGES/djangojs.po
... ... @@ -8,7 +8,7 @@ msgid &quot;&quot;
8 8 msgstr ""
9 9 "Project-Id-Version: PACKAGE VERSION\n"
10 10 "Report-Msgid-Bugs-To: \n"
11   -"POT-Creation-Date: 2021-01-19 10:57+0100\n"
  11 +"POT-Creation-Date: 2021-01-19 13:57+0100\n"
12 12 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13 13 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14 14 "Language-Team: LANGUAGE <LL@li.org>\n"
... ... @@ -179,22 +179,22 @@ msgid &quot;Formularz filtrowania zawiera błędy.&quot;
179 179 msgstr "The filtering form contains errors."
180 180  
181 181 #: entries/static/entries/js/entries2.js:107
182   -#: entries/static/entries/js/forms.js:113
  182 +#: entries/static/entries/js/forms.js:144
183 183 msgid "zwiń"
184 184 msgstr "collapse"
185 185  
186 186 #: entries/static/entries/js/entries2.js:112
187   -#: entries/static/entries/js/forms.js:118
  187 +#: entries/static/entries/js/forms.js:149
188 188 msgid "rozwiń"
189 189 msgstr "expand"
190 190  
191 191 #: entries/static/entries/js/entries2.js:149
192   -#: entries/static/entries/js/forms.js:189
  192 +#: entries/static/entries/js/forms.js:220
193 193 msgid "LUB"
194 194 msgstr "OR"
195 195  
196 196 #: entries/static/entries/js/entries2.js:149
197   -#: entries/static/entries/js/forms.js:189
  197 +#: entries/static/entries/js/forms.js:220
198 198 msgid "Usuń"
199 199 msgstr "Remove"
200 200  
... ... @@ -212,19 +212,19 @@ msgstr &quot;Click to show arguments and phrases linked to this example.&quot;
212 212 msgid "brak haseł"
213 213 msgstr "no entries"
214 214  
215   -#: entries/static/entries/js/forms.js:48
  215 +#: entries/static/entries/js/forms.js:48 entries/static/entries/js/forms.js:110
216 216 msgid "nie"
217 217 msgstr "not"
218 218  
219   -#: entries/static/entries/js/forms.js:62 entries/static/entries/js/forms.js:81
  219 +#: entries/static/entries/js/forms.js:85
220 220 msgid "i"
221 221 msgstr "and"
222 222  
223   -#: entries/static/entries/js/forms.js:62 entries/static/entries/js/forms.js:81
  223 +#: entries/static/entries/js/forms.js:85
224 224 msgid "lub"
225 225 msgstr "or"
226 226  
227   -#: entries/static/entries/js/forms.js:131
  227 +#: entries/static/entries/js/forms.js:162
228 228 msgid ""
229 229 "Łączenie negacji elementu z operatorem ‹inny› na jednym poziomie formularza "
230 230 "jest niemożliwe."
... ... @@ -232,33 +232,33 @@ msgstr &quot;&quot;
232 232 "Mixing element negation with ‹other› operator on the same level is not "
233 233 "possible."
234 234  
235   -#: entries/static/entries/js/forms.js:148
  235 +#: entries/static/entries/js/forms.js:179
236 236 msgid "Kliknij, aby wyłączyć negację tego atrybutu."
237 237 msgstr "Click to switch off negation of this attribute."
238 238  
239   -#: entries/static/entries/js/forms.js:150
  239 +#: entries/static/entries/js/forms.js:181
240 240 msgid "Kliknij, aby zanegować ten atrybut."
241 241 msgstr "Click to negate this attribute."
242 242  
243   -#: entries/static/entries/js/forms.js:174
  243 +#: entries/static/entries/js/forms.js:205
244 244 msgid ""
245 245 "Łączenie operatorów ‹lub› i ‹inny› na jednym poziomie formularza jest "
246 246 "niemożliwe."
247 247 msgstr "Mixing ‹or› and ‹other› operators on the same level is not possible."
248 248  
249   -#: entries/static/entries/js/forms.js:181
  249 +#: entries/static/entries/js/forms.js:212
250 250 msgid "Proszę najpierw dodać element,"
251 251 msgstr "First add an element"
252 252  
253   -#: entries/static/entries/js/forms.js:181
  253 +#: entries/static/entries/js/forms.js:212
254 254 msgid "aby użyć operatora ‹lub›"
255 255 msgstr "in order to use ‹or› operator"
256 256  
257   -#: entries/static/entries/js/forms.js:181
  257 +#: entries/static/entries/js/forms.js:212
258 258 msgid "aby użyć operatora ‹inny›"
259 259 msgstr "in order to use ‹other› operator"
260 260  
261   -#: entries/static/entries/js/forms.js:185
  261 +#: entries/static/entries/js/forms.js:216
262 262 msgid ""
263 263 "Łączenie operatora ‹inny› z negacją elementu na jednym poziomie formularza "
264 264 "jest niemożliwe."
... ... @@ -266,16 +266,16 @@ msgstr &quot;&quot;
266 266 "Mixing ‹other› operator with element negation on the same level is not "
267 267 "possible."
268 268  
269   -#: entries/static/entries/js/forms.js:189
  269 +#: entries/static/entries/js/forms.js:220
270 270 msgid "INNY"
271 271 msgstr "OTHER"
272 272  
273   -#: entries/static/entries/js/forms.js:200
  273 +#: entries/static/entries/js/forms.js:231
274 274 msgid "Wykonanie zapytania z operatorem ‹inny› może trwać zauważalnie dłużej."
275 275 msgstr ""
276 276 "Execution of a query using the ‹other› operator can take considerably longer."
277 277  
278   -#: entries/static/entries/js/forms.js:291
  278 +#: entries/static/entries/js/forms.js:322
279 279 msgid ""
280 280 "Dodanie elementu jest niemożliwe: osiągnięto maksymalny poziom zagnieżdżenia."
281 281 msgstr "Can’t add an element: maximum depth reached."
... ...