lexeme-view.js
7.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
var text_ops = ['eq', 'ne', 'bw', 'bn', 'ew', 'en', 'cn', 'nc', 're', 'nr'];
var eqne = ['eq', 'ne'];
var count_ops = ['eq', 'ge', 'le'];
var extra_attr_filter_fields = {};
$.each($dj.extra_attributes, function(i, attr) {
"use strict";
var filter_field = {
name: 'Atrybut: ' + attr.name,
gender: 'm'
};
if (attr.closed) {
filter_field.ops = eqne;
filter_field.options = attr.options;
} else
filter_field.ops = text_ops;
extra_attr_filter_fields['extra-' + attr.id] = filter_field;
});
$.extend(slickgrid, {
grid_caption: "Leksemy",
grid_element_id: 'lexeme-grid',
main_field: 'entry',
initial_columns: ["entry", "pos"],
initial_sort_rules: ['a_fronte'],
all_columns: {
id: {id: "id", name: "Nr", field: "id"},
entry: {id: "entry", name: "Hasło", field: "entry"},
pos: {id: "pos", name: "Część mowy", field: "pos"},
patterns: {id: "patterns", name: "Wzory", field: "patterns"},
genders: {id: "genders", name: "Rodzaj", field: "genders"},
vocabs: {id: "vocabs", name: "Słowniki", field: "vocabs"},
owner: {id: "owner", name: "Sł. właściciel", field: "owner"},
status: {id: "status", name: "Status", field: "status"}
},
filter_fields: $.extend({
entry: {name: 'Hasło', gender: 'n', ops: text_ops},
part_of_speech: {
name: 'Część mowy',
gender: 'f',
ops: eqne,
options: $dj.parts_of_speech
},
pattern_name: {name: 'Wzór', gender: 'm', ops: text_ops},
pattern_count: {name: 'Liczba wzorów', gender: 'f', ops: count_ops},
pattern_type: {
name: 'Typ wzoru',
gender: 'm',
ops: eqne,
optgroups: $dj.pattern_type_options
},
gender: {
name: 'Rodzaj',
gender: 'm',
ops: eqne,
options: $dj.gender_options
},
gender_count: {name: 'Liczba rodzajów', gender: 'f', ops: count_ops},
form: {name: 'Forma', gender: 'f', ops: text_ops},
containing_vocabulary: {
name: 'Słownik',
gender: 'm',
ops: eqne,
options: $dj.visible_vocabularies
},
owner_vocabulary: {
name: 'Słownik właściciel',
gender: 'm',
ops: eqne,
options: $dj.visible_vocabularies
},
status: {
name: 'Status',
gender: 'm',
ops: eqne,
options: $dj.status_options
},
comment: {name: 'Komentarz', gender: 'm', ops: text_ops},
lexeme_qualifier: {
name: 'Kwal. leksemu',
gender: 'm',
ops: eqne,
options: $dj.qualifier_options
},
lip_qualifier: {
name: 'Kwal. odmieniasia',
gender: 'm',
ops: eqne,
options: $dj.qualifier_options
},
qualifier: {
name: 'Kwal. przy dow. formie',
gender: 'm',
ops: eqne,
options: $dj.qualifier_options
},
qualifiers_dor: {
name: 'Kwal. z Dor.', gender: 'm', ops: text_ops},
qualifiers_style: {
name: 'Kwal. styl.', gender: 'm', ops: text_ops},
qualifiers_scope: {
name: 'Kwal. zakr.', gender: 'm', ops: text_ops},
classification_value: {
name: 'Wartość klasyfikacji',
gender: 'f',
ops: eqne,
options: $dj.cv_options
},
gloss: {name: 'Glosa', gender: 'f', ops: text_ops},
note: {name: 'Nota', gender: 'f', ops: text_ops},
pronunciation: {name: 'Wymowa', gender: 'f', ops: text_ops},
valence: {name: 'Łączliwość', gender: 'f', ops: text_ops},
cr_type: {
name: 'Typ odsyłacza',
gender: 'm',
ops: eqne,
options: $dj.cr_type_options
}
}, extra_attr_filter_fields),
load_content: function(id, is_created) {
"use strict";
function check() {
return id === slickgrid.active_id();
}
edit.busy_on();
edit.load_content(id, is_created, check);
},
update_sort_button: function(sort_rules) {
"use strict";
var icon = $('#sort-button').find('.ui-icon');
var a_fronte = sort_rules[0] === 'a_fronte';
if (a_fronte) {
icon.removeClass('ui-icon-sort-atergo').addClass('ui-icon-sort');
} else {
icon.removeClass('ui-icon-sort').addClass('ui-icon-sort-atergo');
}
var entry_index = slickgrid.grid.getColumnIndex('entry');
if (entry_index !== undefined) {
var columns = slickgrid.grid.getColumns();
if (a_fronte)
columns[entry_index].cssClass = '';
else
columns[entry_index].cssClass = 'atergo';
slickgrid.grid.setColumns(columns);
}
},
row_index: function(id) {
"use strict";
$.ajaxJSON({
url: $dj.ajax_row_index,
method: 'get',
data: {
id: id,
sort_rules: slickgrid.loader.getSort(),
filter: slickgrid.loader.getFilter(),
mask: slickgrid.search_string()
},
callback: function(data) {
var index = data.index;
if (index === null) {
slickgrid.load_content(id);
slickgrid.last_active_row = undefined;
slickgrid.grid.resetActiveCell();
} else {
slickgrid.set_active_when_loaded = index;
slickgrid.grid.scrollRowToCenter(index);
slickgrid.ensure_data();
}
}
});
},
init_sort: function() {
"use strict";
var sort_rules = slickgrid.loader.getSort();
slickgrid.update_sort_button(sort_rules);
$('#sort-button').click(function() {
if (sort_rules[0] === 'a_fronte')
sort_rules[0] = 'a_tergo';
else
sort_rules[0] = 'a_fronte';
slickgrid.update_sort_button(sort_rules);
var active_id = slickgrid.active_id();
slickgrid.loader.setSort(sort_rules);
slickgrid.row_index(active_id);
});
},
init: function() {
"use strict";
$('#lexeme-tabs').on('tabsactivate', function(e, ui) {
if (ui.newPanel.html() === '') {
edit.load_tab(ui.newPanel.attr('id'), edit.get_id());
}
});
}
});
function export_list(filename) {
"use strict";
var param = {
'filter': JSON.stringify(slickgrid.loader.getFilter()),
'sort_rules': JSON.stringify(slickgrid.loader.getSort()),
'columns': JSON.stringify($.map(
slickgrid.grid.getColumns(), function(col) {return col.field;})),
'filename': filename
};
location.href = $dj.ajax_export_list + '?' + $.param(param);
}