|
@@ -19,10 +19,20 @@ let defaultStock = [
|
19
|
19
|
];
|
20
|
20
|
|
21
|
21
|
let currentDataset = [];
|
|
22
|
+let currentTypes = [];
|
22
|
23
|
|
23
|
|
-$(document).ready(function () {
|
24
|
|
- currentDataset = defaultStock;
|
|
24
|
+function initValuesFromPHPDump() {
|
|
25
|
+ currentDataset = json_dump.articles; // json_dump is set using PHP
|
|
26
|
+ currentTypes = json_dump.types;
|
|
27
|
+ console.log(currentDataset);
|
|
28
|
+ console.log(currentTypes);
|
25
|
29
|
generateTable(currentDataset);
|
|
30
|
+}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+$(document).ready(function () {
|
|
35
|
+ initValuesFromPHPDump();
|
26
|
36
|
generateTypeCheckboxes();
|
27
|
37
|
});
|
28
|
38
|
|
|
@@ -57,12 +67,12 @@ function generateLine(item) {
|
57
|
67
|
}
|
58
|
68
|
|
59
|
69
|
function generateTypeCheckboxes() {
|
60
|
|
- for (let i = 0; i < defaultTypes.length; i++) {
|
61
|
|
- let id = 'typeCheck_' + defaultTypes[i];
|
|
70
|
+ for (let i = 0; i < currentTypes.length; i++) {
|
|
71
|
+ let id = 'typeCheck_' + currentTypes[i];
|
62
|
72
|
$('#typeCheckboxesCell').append(
|
63
|
73
|
'<div class="form-check">' +
|
64
|
74
|
'<input type="checkbox" class="form-check-input" id="' + id + '">' +
|
65
|
|
- '<label class="form-check-label" for="' + id + '">' + defaultTypes[i] + '</label>' +
|
|
75
|
+ '<label class="form-check-label" for="' + id + '">' + currentTypes[i] + '</label>' +
|
66
|
76
|
'</div>'
|
67
|
77
|
);
|
68
|
78
|
}
|
|
@@ -119,19 +129,19 @@ function removeItemFromList(item) {
|
119
|
129
|
|
120
|
130
|
function getTypesChecked() {
|
121
|
131
|
let types = [];
|
122
|
|
- for (let i = 0; i < defaultTypes.length; i++) {
|
123
|
|
- let id = 'typeCheck_' + defaultTypes[i];
|
|
132
|
+ for (let i = 0; i < currentTypes.length; i++) {
|
|
133
|
+ let id = 'typeCheck_' + currentTypes[i];
|
124
|
134
|
if ($('#' + id).is(':checked')) {
|
125
|
|
- types.push(defaultTypes[i]);
|
|
135
|
+ types.push(currentTypes[i]);
|
126
|
136
|
}
|
127
|
137
|
}
|
128
|
138
|
return types;
|
129
|
139
|
}
|
130
|
140
|
|
131
|
141
|
function setTypesChecked(types) {
|
132
|
|
- for (let i = 0; i < defaultTypes.length; i++) {
|
133
|
|
- let id = 'typeCheck_' + defaultTypes[i];
|
134
|
|
- $('#' + id).prop('checked', types.indexOf(defaultTypes[i]) !== -1);
|
|
142
|
+ for (let i = 0; i < currentTypes.length; i++) {
|
|
143
|
+ let id = 'typeCheck_' + currentTypes[i];
|
|
144
|
+ $('#' + id).prop('checked', types.indexOf(currentTypes[i]) !== -1);
|
135
|
145
|
}
|
136
|
146
|
return types;
|
137
|
147
|
}
|
|
@@ -179,7 +189,7 @@ function isItemInputFilled() {
|
179
|
189
|
|
180
|
190
|
function saveDataset() {
|
181
|
191
|
let finalDataset = {
|
182
|
|
- types: defaultTypes,
|
|
192
|
+ types: currentTypes,
|
183
|
193
|
articles: currentDataset
|
184
|
194
|
};
|
185
|
195
|
console.log(finalDataset);
|