var db_table = {}; function get_value_list_by_key(obj_list, key_search, target_value, key_save) { output_list = []; obj_list.forEach(element => { if (target_value.length) { target_value.forEach(e => { if(e.toString() == element[key_search].toString()) { output_list.push(element[key_save]); } }); } else { output_list.push(element[key_save]); } }); output_list = [...new Set(output_list)]; return output_list; } function merge_object_by_key(obj, key, value) { output_object = {}; while (obj.length > 0) { pop_out = obj.pop(); if (output_object[pop_out[key]] == undefined) { output_object[pop_out[key]] = [pop_out[value]]; } else { output_object[pop_out[key]].push(pop_out[value]); } } return output_object } $.ajax({ url: "./script/php/get_db_table.php", type: "GET", async: false, contentType: "application/json", dataType: "json" }).done(function(data) { db_table = data; }).error(function(error) { console.log(error); }); db_table["notes"] = merge_object_by_key(db_table["notes"], "project_id", "notes"); var notes_button_list = [...new Set([].concat(...Object.values(db_table["notes"])))]; var search_data = { "category": get_value_list_by_key(db_table["category"], null, [], "category_id"), "project": get_value_list_by_key(db_table["project"], null, [], "project_id"), "type": get_value_list_by_key(db_table["type"], null, [], "type_id"), "notes": notes_button_list }; const vm = Vue.createApp({}); vm.component('search-block', { data() { return { category_list: db_table["category"], project_list: db_table["project"], type_list: db_table["type"], notes_button_list: notes_button_list } }, template: `
` }); vm.component("multi-select", { template: `
`, props: { object: { category_name: String, category_id: String, list_id: String }, }, computed: { id_concat(){ return "category" + this.object.category_id + "-" + this.object.list_id; } } }); vm.component("checkbox-option", { template: ``, props: { object: { category_name: String, category_id: String, list_id: String }, }, computed: { id_concat(){ return "category" + this.object.category_id + "-" + this.object.list_id; } } }); vm.component('category-button', { template: ``, props: { object: { category_name: String, category_id: String, list_id: String }, }, computed: { id_concat(){ return "category" + this.object.category_id + "-" + this.object.list_id; } } }); vm.component('project-button', { template: ``, props: { object: { project_id: String, project_name: String, category_id: String }, }, computed: { id_concat(){ return "project" + this.object.project_id; } } }); vm.component('type-button', { template: ``, props: { object: { type_id: String, type_name: String, filetype_id: String }, } }); vm.component('notes-button', { template: ``, props: { object: String } });