Merge branch 'master' into develop

This commit is contained in:
Keviin Åberg Kultalahti 2021-08-13 14:41:49 +02:00
commit 97498b0778
2 changed files with 21 additions and 3 deletions

View File

@ -13,8 +13,9 @@
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
const onChange = e => { const onChange = e => {
value = e.detail const isoString = e.detail.toISOString()
dispatch("change", e.detail) value = isoString
dispatch("change", isoString)
} }
</script> </script>

View File

@ -1,6 +1,10 @@
const CouchDB = require("../index") const CouchDB = require("../index")
const { IncludeDocs, getLinkDocuments } = require("./linkUtils") const { IncludeDocs, getLinkDocuments } = require("./linkUtils")
const { generateLinkID } = require("../utils") const {
generateLinkID,
InternalTables,
getUserMetadataParams,
} = require("../utils")
const Sentry = require("@sentry/node") const Sentry = require("@sentry/node")
const { FieldTypes, RelationshipTypes } = require("../../constants") const { FieldTypes, RelationshipTypes } = require("../../constants")
@ -208,6 +212,19 @@ class LinkController {
const linkedTable = await this._db.get(field.tableId) const linkedTable = await this._db.get(field.tableId)
const linkedSchema = linkedTable.schema[field.fieldName] const linkedSchema = linkedTable.schema[field.fieldName]
// We need to map the global users to metadata in each app for relationships
if (field.tableId === InternalTables.USER_METADATA) {
const users = await this._db.allDocs(getUserMetadataParams(null, {}))
const metadataRequired = rowField.filter(
userId => !users.rows.some(user => user.id === userId)
)
// ensure non-existing user metadata is created in the app DB
await this._db.bulkDocs(
metadataRequired.map(userId => ({ _id: userId }))
)
}
// iterate through the link IDs in the row field, see if any don't exist already // iterate through the link IDs in the row field, see if any don't exist already
for (let linkId of rowField) { for (let linkId of rowField) {
if (linkedSchema.relationshipType === RelationshipTypes.ONE_TO_MANY) { if (linkedSchema.relationshipType === RelationshipTypes.ONE_TO_MANY) {