Skip to content
Snippets Groups Projects
Commit c3540b43 authored by Deleted User's avatar Deleted User
Browse files

Try to create a hierarchy for add label.

parent 20b081ff
No related branches found
No related tags found
2 merge requests!16Correction Push,!15correction
......@@ -14,6 +14,11 @@
<br>
</span>
{{ labels_add }}
<br>
<span v-for='(value, index) in all_labels'>
<span v-if="value[2] == 1"><ul>{{ value[1] }}</span>
<span v-else></span></ul><li>{{ value[1] }}</li></span>
</span>
</div>
<div id='form'>
......@@ -42,13 +47,28 @@
return (result);
}
function get_all_childs_of_father(tab_labels, father_id) {
/**
* Gets all the childs (label id) from a father.
*/
var childs = [];
for (var i = 0; tab_labels[i]; i++) {
if (tab_labels[i][2] == father_id) {
childs.push(tab_labels[i][0])
childs = childs.concat(get_all_childs_of_father(tab_labels, tab_labels[i][0]));
}
}
return (childs);
}
var hierarchy = new Vue({
el: '#hierarchy',
data: {
all_labels: [],
table: order_intent_labels_tab(),
is_active: create_empty_tab(40),
labels_add: []
labels_add: [],
ok: [1, 0, 1, 0, 0, 1, 0, 0]
},
methods: {
activate_lo: function (index) {
......@@ -61,14 +81,18 @@
document.form1.labels.value = this.labels_add;
},
get_all_labels: function() {
this.all_labels = JSON.parse(request_ajax("labels"));
return (JSON.parse(request_ajax("labels")));
}
}
});
/*hierarchy.all_labels = hierarchy.get_all_labels();
hierarchy.all_labels = hierarchy.get_all_labels();
for (var i = 0; hierarchy.all_labels[i]; i++) {
console.log(get_all_childs_of_father(hierarchy.all_labels, hierarchy.all_labels[i][0]));
}*/
}
for (var i = 0; hierarchy.all_labels[i]; i++) {
hierarchy.all_labels[i][2] = hierarchy.ok[i];
}
</script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment