@mongoosejs/studio 0.0.40 → 0.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/backend/actions/Model/updateDocument.js +8 -1
- package/frontend/public/app.js +24 -8
- package/frontend/public/tw.css +17 -459
- package/frontend/src/edit-date/edit-date.html +12 -2
- package/frontend/src/edit-date/edit-date.js +19 -1
- package/frontend/src/index.js +1 -1
- package/index.d.ts +5 -1
- package/mongoosejs-studio-0.0.16.tgz +0 -0
- package/package.json +1 -1
- package/frontend/dist/app.js +0 -160
- package/frontend/dist/tw.css +0 -595
|
@@ -25,8 +25,15 @@ module.exports = ({ db }) => async function updateDocument(params) {
|
|
|
25
25
|
throw new Error(`Model ${model} not found`);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
let processedUpdate = update;
|
|
29
|
+
if (Object.keys(update).length > 0) {
|
|
30
|
+
processedUpdate = Object.fromEntries(
|
|
31
|
+
Object.entries(update).map(([key, value]) => [key, value === 'null' ? null : value === 'undefined' ? undefined : value])
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
28
35
|
const doc = await Model.
|
|
29
|
-
findByIdAndUpdate(_id,
|
|
36
|
+
findByIdAndUpdate(_id, processedUpdate, { sanitizeFilter: true, returnDocument: 'after', overwriteImmutable: true, runValidators: false });
|
|
30
37
|
|
|
31
38
|
return { doc };
|
|
32
39
|
};
|
package/frontend/public/app.js
CHANGED
|
@@ -970,6 +970,24 @@ module.exports = app => app.component('edit-date', {
|
|
|
970
970
|
data: () => ({
|
|
971
971
|
inputType: ''
|
|
972
972
|
}),
|
|
973
|
+
methods: {
|
|
974
|
+
updateFromISO($event) {
|
|
975
|
+
const value = $event.target.value;
|
|
976
|
+
if (value == null) {
|
|
977
|
+
return this.$emit('input', $event.target.value);
|
|
978
|
+
}
|
|
979
|
+
if (value === 'null') {
|
|
980
|
+
return this.$emit('input', null);
|
|
981
|
+
}
|
|
982
|
+
if (value === 'undefined') {
|
|
983
|
+
return this.$emit('input', undefined);
|
|
984
|
+
}
|
|
985
|
+
const valueAsDate = new Date(value);
|
|
986
|
+
if (!isNaN(valueAsDate.valueOf())) {
|
|
987
|
+
this.$emit('input', $event.target.value);
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
},
|
|
973
991
|
computed: {
|
|
974
992
|
valueAsLocalString() {
|
|
975
993
|
if (this.value == null) {
|
|
@@ -990,7 +1008,7 @@ module.exports = app => app.component('edit-date', {
|
|
|
990
1008
|
},
|
|
991
1009
|
valueAsISOString() {
|
|
992
1010
|
if (this.value == null) {
|
|
993
|
-
return this.value;
|
|
1011
|
+
return '' + this.value;
|
|
994
1012
|
}
|
|
995
1013
|
const date = new Date(this.value);
|
|
996
1014
|
return date.toISOString();
|
|
@@ -1644,8 +1662,9 @@ module.exports = app => app.component('models', {
|
|
|
1644
1662
|
} else {
|
|
1645
1663
|
this.filter = {};
|
|
1646
1664
|
delete this.query.search;
|
|
1665
|
+
this.$router.push({ query: this.query });
|
|
1647
1666
|
}
|
|
1648
|
-
await this.loadMoreDocuments(
|
|
1667
|
+
await this.loadMoreDocuments();
|
|
1649
1668
|
},
|
|
1650
1669
|
async getDocuments() {
|
|
1651
1670
|
const { docs, schemaPaths, numDocs } = await api.Model.getDocuments({
|
|
@@ -1677,7 +1696,7 @@ module.exports = app => app.component('models', {
|
|
|
1677
1696
|
this.filteredPaths = [...this.schemaPaths];
|
|
1678
1697
|
this.selectedPaths = [...this.schemaPaths];
|
|
1679
1698
|
},
|
|
1680
|
-
async loadMoreDocuments(
|
|
1699
|
+
async loadMoreDocuments() {
|
|
1681
1700
|
const { docs } = await api.Model.getDocuments({
|
|
1682
1701
|
model: this.currentModel,
|
|
1683
1702
|
filter: this.filter,
|
|
@@ -1688,9 +1707,6 @@ module.exports = app => app.component('models', {
|
|
|
1688
1707
|
if (docs.length < limit) {
|
|
1689
1708
|
this.loadedAllDocs = true;
|
|
1690
1709
|
}
|
|
1691
|
-
if (updateQuery) {
|
|
1692
|
-
this.$router.push({ query: this.query });
|
|
1693
|
-
}
|
|
1694
1710
|
},
|
|
1695
1711
|
addOrRemove(path) {
|
|
1696
1712
|
const exists = this.selectedPaths.findIndex(x => x.path == path.path);
|
|
@@ -2682,7 +2698,7 @@ module.exports = "<div class=\"edit-array\">\n <textarea\n ref=\"arrayEditor
|
|
|
2682
2698
|
/***/ ((module) => {
|
|
2683
2699
|
|
|
2684
2700
|
"use strict";
|
|
2685
|
-
module.exports = "<div>\n <input
|
|
2701
|
+
module.exports = "<div>\n <input\n v-if=\"dateSelection == 'picker'\"\n class=\"w-64 h-8 border border-gray-300 outline-0\"\n type=\"datetime-local\"\n :value=\"valueAsLocalString\"\n @input=\"$emit('input', $event.target.value)\">\n <input\n v-if=\"dateSelection == 'iso'\"\n type=\"text\"\n class=\"w-64 h-8 border border-gray-300 outline-0\"\n :value=\"valueAsISOString\"\n @input=\"updateFromISO\">\n</div>";
|
|
2686
2702
|
|
|
2687
2703
|
/***/ }),
|
|
2688
2704
|
|
|
@@ -10634,7 +10650,7 @@ app.component('app-component', {
|
|
|
10634
10650
|
`,
|
|
10635
10651
|
errorCaptured(err) {
|
|
10636
10652
|
vanillatoasts.create({
|
|
10637
|
-
title: `Error: ${err.
|
|
10653
|
+
title: `Error: ${err.message}`,
|
|
10638
10654
|
icon: 'images/failure.jpg',
|
|
10639
10655
|
timeout: 10000,
|
|
10640
10656
|
positionClass: 'bottomRight'
|