Added basic visibility feature
This commit is contained in:
parent
8e189a9e7c
commit
a0ef6e7dff
7 changed files with 101 additions and 16 deletions
|
@ -86,7 +86,8 @@ class JsonBuilder
|
||||||
"record_tag_id" => "",
|
"record_tag_id" => "",
|
||||||
"name" => "",
|
"name" => "",
|
||||||
"user_id" => "",
|
"user_id" => "",
|
||||||
"visible" => ""
|
"visible" => "",
|
||||||
|
"bundle" => ""
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->jsonData['record_tags'] = array();
|
$this->jsonData['record_tags'] = array();
|
||||||
|
|
|
@ -248,7 +248,7 @@ function updateRecordTag($user_id, $tag)
|
||||||
|
|
||||||
// Update given parameters
|
// Update given parameters
|
||||||
$data = [];
|
$data = [];
|
||||||
$props = ["name", "visible"];
|
$props = ["name", "visible", "bundle"];
|
||||||
foreach ($props as $p) {
|
foreach ($props as $p) {
|
||||||
if (array_key_exists ($p, $tag)) {
|
if (array_key_exists ($p, $tag)) {
|
||||||
$data[$p] = $tag[$p];
|
$data[$p] = $tag[$p];
|
||||||
|
@ -373,7 +373,9 @@ function getRecordExternalData($record)
|
||||||
$data = [
|
$data = [
|
||||||
"record_tag_id" => $tag["record_tag_id"],
|
"record_tag_id" => $tag["record_tag_id"],
|
||||||
"name" => $tag["name"],
|
"name" => $tag["name"],
|
||||||
"user_id" => $tag["user_id"]
|
"user_id" => $tag["user_id"],
|
||||||
|
"visible" => $tag["visible"],
|
||||||
|
"bundle" => $tag["bundle"]
|
||||||
];
|
];
|
||||||
$tags[] = $data;
|
$tags[] = $data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,6 @@ export default {
|
||||||
created: function() {
|
created: function() {
|
||||||
this.form.record_tag_id = this.tag.record_tag_id;
|
this.form.record_tag_id = this.tag.record_tag_id;
|
||||||
this.form.name = this.tag.name;
|
this.form.name = this.tag.name;
|
||||||
console.log(this.tag);
|
|
||||||
this.form.visible = this.tag.visible;
|
this.form.visible = this.tag.visible;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<b-table
|
<b-table
|
||||||
:items="records"
|
:items="shownRecords"
|
||||||
hover
|
hover
|
||||||
:busy="isLoading"
|
:busy="isLoading"
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
|
@ -27,7 +27,10 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #cell(tags)="data">
|
<template #cell(tags)="data">
|
||||||
<JugglTagField :recordId="data.item.record_id" />
|
<JugglTagField
|
||||||
|
:recordId="data.item.record_id"
|
||||||
|
:onlyVisible="onlyVisibleTags"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #cell(details)="data">
|
<template #cell(details)="data">
|
||||||
|
@ -90,6 +93,16 @@ export default {
|
||||||
required: false,
|
required: false,
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
},
|
||||||
|
onlyVisibleTags: {
|
||||||
|
required: false,
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
onlyVisibleProjects: {
|
||||||
|
required: false,
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
@ -137,6 +150,24 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
return fields;
|
return fields;
|
||||||
|
},
|
||||||
|
shownRecords: function() {
|
||||||
|
if (!this.onlyVisibleProjects) {
|
||||||
|
return this.records;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only return records from visible projects
|
||||||
|
var visibleProjects = store.getters.visibleProjects;
|
||||||
|
var visibleIds = [];
|
||||||
|
Object.values(visibleProjects)
|
||||||
|
.filter(p => p.visible)
|
||||||
|
.forEach(p => {
|
||||||
|
visibleIds.push(p.project_id);
|
||||||
|
});
|
||||||
|
|
||||||
|
return Object.values(this.records).filter(r =>
|
||||||
|
visibleIds.includes(r.project_id)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div :id="containerId" class="tag-container">
|
<div :id="containerId" class="tag-container">
|
||||||
|
<!-- Tag item list -->
|
||||||
<div
|
<div
|
||||||
class="tag-item"
|
class="tag-item"
|
||||||
v-for="tag in addedTags"
|
v-for="tag in addedTags"
|
||||||
|
@ -9,10 +10,12 @@
|
||||||
{{ tag.name }}
|
{{ tag.name }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Add-button -->
|
||||||
<div :id="btnId">
|
<div :id="btnId">
|
||||||
<b-icon icon="plus" />
|
<b-icon icon="plus" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Popover -->
|
||||||
<b-popover
|
<b-popover
|
||||||
:target="btnId"
|
:target="btnId"
|
||||||
triggers="click"
|
triggers="click"
|
||||||
|
@ -53,6 +56,11 @@ export default {
|
||||||
props: {
|
props: {
|
||||||
recordId: {
|
recordId: {
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
onlyVisible: {
|
||||||
|
required: false,
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
@ -95,10 +103,17 @@ export default {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
allTags: function() {
|
allTags: function() {
|
||||||
return store.getters.tags;
|
if (this.onlyVisible) {
|
||||||
|
return store.getters.getFilteredTags({ visible: true });
|
||||||
|
} else {
|
||||||
|
return store.getters.tags;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
addedTags: function() {
|
addedTags: function() {
|
||||||
return this.record.tags;
|
Object.values(this.record.tags).forEach(t => console.log(t.visible));
|
||||||
|
return Object.values(this.record.tags).filter(
|
||||||
|
t => !this.onlyVisible || t.visible
|
||||||
|
);
|
||||||
},
|
},
|
||||||
usedTagIds: function() {
|
usedTagIds: function() {
|
||||||
var ids = [];
|
var ids = [];
|
||||||
|
|
|
@ -73,10 +73,10 @@ export const juggl = {
|
||||||
return getters.projectIds.filter(id => !runningProjectIds.includes(id));
|
return getters.projectIds.filter(id => !runningProjectIds.includes(id));
|
||||||
},
|
},
|
||||||
finishedProjects: (state, getters) => {
|
finishedProjects: (state, getters) => {
|
||||||
var ids = getters.finishedProjectIds;
|
return getters.getFilteredProjects({ finished: true });
|
||||||
return Object.values(state.projects).filter(project =>
|
},
|
||||||
ids.includes(project.project_id)
|
visibleProjects: (state, getters) => {
|
||||||
);
|
return getters.getFilteredProjects({ visible: true });
|
||||||
},
|
},
|
||||||
runningProjects: (state, getters) => {
|
runningProjects: (state, getters) => {
|
||||||
var ids = getters.runningProjectIds;
|
var ids = getters.runningProjectIds;
|
||||||
|
@ -89,6 +89,43 @@ export const juggl = {
|
||||||
project => project.project_id === id
|
project => project.project_id === id
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
getFilteredProjects: (state, getters) => ({
|
||||||
|
finished = undefined,
|
||||||
|
visible = undefined,
|
||||||
|
projects = undefined
|
||||||
|
}) => {
|
||||||
|
if (projects == undefined) {
|
||||||
|
projects = getters.projects;
|
||||||
|
}
|
||||||
|
|
||||||
|
var runningIds = getters.runningProjectIds;
|
||||||
|
return Object.values(projects).filter(project => {
|
||||||
|
var projectFinished = !runningIds.includes(project.project_id);
|
||||||
|
|
||||||
|
if (finished !== undefined && finished !== projectFinished) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (visible !== undefined && visible !== project.visible) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getFilteredTags: (state, getters) => ({
|
||||||
|
visible = undefined,
|
||||||
|
tags = undefined
|
||||||
|
}) => {
|
||||||
|
if (tags == undefined) {
|
||||||
|
tags = getters.tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Object.values(tags).filter(tag => {
|
||||||
|
if (visible != undefined && visible !== tag.visible) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
},
|
||||||
getTagById: (state, getters) => id => {
|
getTagById: (state, getters) => id => {
|
||||||
return Object.values(getters.tags).find(tag => tag.record_tag_id === id);
|
return Object.values(getters.tags).find(tag => tag.record_tag_id === id);
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
<JugglRecordsList :records="runningRecords" running />
|
<JugglRecordsList :records="runningRecords" running />
|
||||||
</BaseSection>
|
</BaseSection>
|
||||||
<BaseSection title="Projects">
|
<BaseSection title="Projects">
|
||||||
<div v-if="finishedProjects.length > 0">
|
<div v-if="availableProjects.length > 0">
|
||||||
<JugglProjectsPanel :projects="finishedProjects" />
|
<JugglProjectsPanel :projects="availableProjects" />
|
||||||
</div>
|
</div>
|
||||||
<div id="add-project-form">
|
<div id="add-project-form">
|
||||||
<FormProjectAdd />
|
<FormProjectAdd />
|
||||||
|
@ -43,8 +43,8 @@ export default {
|
||||||
BaseSection
|
BaseSection
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
finishedProjects: () => {
|
availableProjects: () => {
|
||||||
return store.getters.finishedProjects;
|
return store.getters.getFilteredProjects({finished: true, visible: true});
|
||||||
},
|
},
|
||||||
finishedRecords: () => {
|
finishedRecords: () => {
|
||||||
return store.getters.finishedRecords;
|
return store.getters.finishedRecords;
|
||||||
|
|
Loading…
Reference in a new issue