This commit is contained in:
zadam 2023-06-05 21:14:33 +02:00
parent 00453fc151
commit 69c7eb14aa
10 changed files with 16 additions and 7 deletions

View file

@ -93,6 +93,8 @@ class AbstractBeccaEntity {
const pojo = this.getPojoToSave();
console.log(pojo);
sql.transactional(() => {
sql.upsert(entityName, primaryKeyName, pojo);

View file

@ -190,7 +190,7 @@ class BAttribute extends AbstractBeccaEntity {
if (this.position === undefined || this.position === null) {
const maxExistingPosition = this.getNote().getAttributes()
.reduce((maxPosition, attr) => Math.max(maxPosition, attr.position), 0);
.reduce((maxPosition, attr) => Math.max(maxPosition, attr.position || 0), 0);
this.position = maxExistingPosition + 10;
}

View file

@ -117,6 +117,10 @@ export default class LoadResults {
return this.optionNames.includes(name);
}
getOptionNames() {
return this.optionNames;
}
addAttachmentRow(attachment) {
this.attachmentRows.push(attachment);
}

View file

@ -50,7 +50,7 @@ export default class OptionsWidget extends NoteContextAwareWidget {
}
async entitiesReloadedEvent({loadResults}) {
if (loadResults.options.length > 0) {
if (loadResults.getOptionNames().length > 0) {
this.refresh();
}
}

View file

@ -150,7 +150,10 @@ function fillInAdditionalProperties(entityChange) {
} else if (entityChange.entityName === 'blobs') {
entityChange.noteIds = sql.getColumn("SELECT noteId FROM notes WHERE blobId = ? AND isDeleted = 0", [entityChange.entityId]);
} else if (entityChange.entityName === 'attachments') {
entityChange.entity = becca.getAttachment(entityChange.entityId, {includeContentLength: true});
entityChange.entity = sql.getRow(`SELECT attachments.*, LENGTH(blobs.content) AS contentLength
FROM attachments
JOIN blobs USING (blobId)
WHERE attachmentId = ?`, [entityChange.entityId]);
}
if (entityChange.entity instanceof AbstractBeccaEntity) {

View file

@ -85,7 +85,7 @@ Authorization: {{authToken}}
> {%
client.assert(response.status === 200);
client.assert(response.body.branchId == client.global.get("clonedBranchId"));
client.assert(response.body.parentNoteId == '_hidden');
client.assert(response.body.parentNoteId == "_hidden");
%}
###

View file

@ -22,7 +22,7 @@ Content-Type: application/json
{
"noteId": "{{createdNoteId}}",
"parentNoteId": '_hidden'
"parentNoteId": "_hidden"
}
> {% client.global.set("clonedBranchId", response.body.branchId); %}

View file

@ -38,7 +38,7 @@ Content-Type: application/json
{
"noteId": "{{createdNoteId}}",
"parentNoteId": '_hidden'
"parentNoteId": "_hidden"
}
> {% client.global.set("clonedBranchId", response.body.branchId); %}

View file

@ -21,5 +21,5 @@ Authorization: {{authToken}}
> {%
client.assert(response.status === 200);
client.assert(response.body === "<p>Hi there!</p>");
client.assert(response.body === "Hi there!");
%}