diff --git a/model/meta.js b/model/meta.js
index 38d6a4ac..2edbceff 100644
--- a/model/meta.js
+++ b/model/meta.js
@@ -1,6 +1,7 @@
const BaseDocument = require('./document');
const frappe = require('frappejs');
const model = require('./index')
+const indicatorColor = require('frappejs/ui/constants/indicators');
module.exports = class BaseMeta extends BaseDocument {
constructor(data) {
@@ -185,8 +186,8 @@ module.exports = class BaseMeta extends BaseDocument {
this.indicators = {
key: 'submitted',
colors: {
- 0: 'gray',
- 1: 'blue'
+ 0: indicatorColor.GRAY,
+ 1: indicatorColor.BLUE
}
}
}
@@ -195,17 +196,17 @@ module.exports = class BaseMeta extends BaseDocument {
getIndicatorColor(doc) {
if (frappe.isDirty(this.name, doc.name)) {
- return 'orange';
+ return indicatorColor.ORANGE;
} else {
if (this.indicators) {
let value = doc[this.indicators.key];
if (value) {
- return this.indicators.colors[value] || 'gray';
+ return this.indicators.colors[value] || indicatorColor.GRAY;
} else {
- return 'gray';
+ return indicatorColor.GRAY;
}
} else {
- return 'gray';
+ return indicatorColor.GRAY;
}
}
}
diff --git a/models/doctype/ToDo/ToDo.js b/models/doctype/ToDo/ToDo.js
index 4d5ff427..a0ff1d49 100644
--- a/models/doctype/ToDo/ToDo.js
+++ b/models/doctype/ToDo/ToDo.js
@@ -1,3 +1,5 @@
+const indicatorColor = require('frappejs/ui/constants/indicators');
+
module.exports = {
name: "ToDo",
label: "To Do",
@@ -14,8 +16,8 @@ module.exports = {
indicators: {
key: 'status',
colors: {
- Open: 'gray',
- Closed: 'green'
+ Open: indicatorColor.BLUE,
+ Closed: indicatorColor.GREEN
}
},
"fields": [
diff --git a/ui/components/Indicator.vue b/ui/components/Indicator.vue
index 23893bbf..98b09f82 100644
--- a/ui/components/Indicator.vue
+++ b/ui/components/Indicator.vue
@@ -2,8 +2,24 @@
@@ -14,11 +30,31 @@ export default {
display: inline-block;
width: 0.5rem;
height: 0.5rem;
- background-color: $gray-400;
border-radius: 50%;
}
+.indicator-grey {
+ background-color: $gray-300;
+}
.indicator-blue {
- background-color: $primary;
+ background-color: $blue;
+}
+.indicator-red {
+ background-color: $red;
+}
+.indicator-green {
+ background-color: $green;
+}
+.indicator-orange {
+ background-color: $orange;
+}
+.indicator-purple {
+ background-color: $purple;
+}
+.indicator-yellow {
+ background-color: $yellow;
+}
+.indicator-black {
+ background-color: $gray-800;
}
diff --git a/ui/components/List/List.vue b/ui/components/List/List.vue
index 9c2b851f..5e4386d8 100644
--- a/ui/components/List/List.vue
+++ b/ui/components/List/List.vue
@@ -12,8 +12,12 @@
:isActive="doc.name === $route.params.name"
:isChecked="isChecked(doc.name)"
@clickItem="openForm(doc.name)"
- @checkItem="toggleCheck(doc.name)">
- {{ doc[meta.titleField || 'name'] }}
+ @checkItem="toggleCheck(doc.name)"
+ >
+
+
+ {{ doc[meta.titleField || 'name'] }}
+
@@ -27,20 +31,23 @@ export default {
name: 'List',
props: ['doctype', 'filters'],
components: {
- ListActions,
- ListItem
+ ListActions,
+ ListItem
},
data() {
- return {
- data: [],
- checkList: [],
- activeItem: ''
- }
+ return {
+ data: [],
+ checkList: [],
+ activeItem: ''
+ };
},
computed: {
- meta() {
- return frappe.getMeta(this.doctype);
- }
+ meta() {
+ return frappe.getMeta(this.doctype);
+ },
+ hasIndicator() {
+ return Boolean(this.meta.indicators);
+ }
},
created() {
frappe.db.on(`change:${this.doctype}`, () => {
@@ -52,21 +59,29 @@ export default {
},
methods: {
async newDoc() {
- let doc = await frappe.getNewDoc(this.doctype);
- this.$router.push(`/edit/${this.doctype}/${doc.name}`);
+ let doc = await frappe.getNewDoc(this.doctype);
+ this.$router.push(`/edit/${this.doctype}/${doc.name}`);
},
async updateList() {
+ const indicatorField = this.hasIndicator ? this.meta.indicators.key : null;
+ const fields = [
+ 'name',
+ indicatorField,
+ this.meta.titleField,
+ ...this.meta.keywordFields
+ ].filter(Boolean);
+
const data = await frappe.db.getAll({
doctype: this.doctype,
- fields: ['name', ...this.meta.keywordFields, this.meta.titleField],
+ fields,
filters: this.filters || null
});
this.data = data;
},
openForm(name) {
- this.activeItem = name;
- this.$router.push(`/edit/${this.doctype}/${name}`);
+ this.activeItem = name;
+ this.$router.push(`/edit/${this.doctype}/${name}`);
},
async deleteCheckedItems() {
await frappe.db.deleteMany(this.doctype, this.checkList);
@@ -74,31 +89,34 @@ export default {
},
toggleCheck(name) {
if (this.checkList.includes(name)) {
- this.checkList = this.checkList.filter(docname => docname !== name);
+ this.checkList = this.checkList.filter(docname => docname !== name);
} else {
- this.checkList = this.checkList.concat(name);
+ this.checkList = this.checkList.concat(name);
}
},
isChecked(name) {
return this.checkList.includes(name);
+ },
+ getIndicatorColor(doc) {
+ return this.meta.getIndicatorColor(doc);
}
}
-}
+};
diff --git a/ui/constants/indicators.js b/ui/constants/indicators.js
new file mode 100644
index 00000000..96f3f101
--- /dev/null
+++ b/ui/constants/indicators.js
@@ -0,0 +1,11 @@
+module.exports = {
+ GRAY: 'grey',
+ GREY: 'grey',
+ BLUE: 'blue',
+ RED: 'red',
+ GREEN: 'green',
+ ORANGE: 'orange',
+ PURPLE: 'purple',
+ YELLOW: 'yellow',
+ BLACK: 'black',
+}
\ No newline at end of file