hadron-document
Advanced tools
Comparing version 0.0.0-next-4da646a12b2e0ba41483ebf5a98cd74907a22e10 to 0.0.0-next-4eaf0370d44a91ba9c196f41774c1b6b61b5029c
@@ -12,2 +12,6 @@ import type { Element } from './element'; | ||
VisibleElementsChanged: string; | ||
EditingStarted: string; | ||
EditingFinished: string; | ||
MarkedForDeletion: string; | ||
DeletionFinished: string; | ||
}; | ||
@@ -26,2 +30,4 @@ export declare const DEFAULT_VISIBLE_ELEMENTS = 25; | ||
maxVisibleElementsCount: number; | ||
editing: boolean; | ||
markedForDeletion: boolean; | ||
cancel(): void; | ||
@@ -62,4 +68,15 @@ constructor(doc: BSONObject, cloned?: boolean); | ||
getTotalVisibleElementsCount(): number; | ||
startEditing(elementId?: string, field?: 'key' | 'value' | 'type'): void; | ||
finishEditing(): void; | ||
onUpdateStart(): void; | ||
onUpdateSuccess(doc: Record<string, unknown>): void; | ||
onUpdateBlocked(): void; | ||
onUpdateError(error: Error): void; | ||
markForDeletion(): void; | ||
finishDeletion(): void; | ||
onRemoveStart(): void; | ||
onRemoveSuccess(): void; | ||
onRemoveError(error: Error): void; | ||
} | ||
export default Document; | ||
//# sourceMappingURL=document.d.ts.map |
@@ -12,2 +12,3 @@ 'use strict'; | ||
const utils_1 = require("./utils"); | ||
const _1 = require("."); | ||
exports.Events = { | ||
@@ -18,2 +19,6 @@ Cancel: 'Document::Cancel', | ||
VisibleElementsChanged: 'Document::VisibleElementsChanged', | ||
EditingStarted: 'Document::EditingStarted', | ||
EditingFinished: 'Document::EditingFinished', | ||
MarkedForDeletion: 'Document::MarkedForDeletion', | ||
DeletionFinished: 'Document::DeletionFinished', | ||
}; | ||
@@ -34,2 +39,4 @@ const ID = '_id'; | ||
this.maxVisibleElementsCount = exports.DEFAULT_VISIBLE_ELEMENTS; | ||
this.editing = false; | ||
this.markedForDeletion = false; | ||
this.uuid = new bson_1.UUID().toHexString(); | ||
@@ -214,2 +221,49 @@ this.doc = doc; | ||
} | ||
startEditing(elementId, field) { | ||
if (!this.editing) { | ||
this.editing = true; | ||
this.emit(_1.DocumentEvents.EditingStarted, elementId, field); | ||
} | ||
} | ||
finishEditing() { | ||
if (this.editing) { | ||
this.editing = false; | ||
this.emit(_1.DocumentEvents.EditingFinished); | ||
} | ||
} | ||
onUpdateStart() { | ||
this.emit('update-start'); | ||
} | ||
onUpdateSuccess(doc) { | ||
this.emit('update-success', doc); | ||
this.finishEditing(); | ||
} | ||
onUpdateBlocked() { | ||
this.emit('update-blocked'); | ||
} | ||
onUpdateError(error) { | ||
this.emit('update-error', error.message); | ||
} | ||
markForDeletion() { | ||
if (!this.markedForDeletion) { | ||
this.markedForDeletion = true; | ||
this.emit(_1.DocumentEvents.MarkedForDeletion); | ||
} | ||
} | ||
finishDeletion() { | ||
if (this.markedForDeletion) { | ||
this.markedForDeletion = false; | ||
this.emit(_1.DocumentEvents.DeletionFinished); | ||
} | ||
} | ||
onRemoveStart() { | ||
this.emit('remove-start'); | ||
} | ||
onRemoveSuccess() { | ||
this.emit('remove-success'); | ||
this.finishDeletion(); | ||
} | ||
onRemoveError(error) { | ||
this.emit('remove-error', error.message); | ||
} | ||
} | ||
@@ -216,0 +270,0 @@ exports.Document = Document; |
@@ -10,3 +10,3 @@ { | ||
"homepage": "https://github.com/mongodb-js/compass", | ||
"version": "0.0.0-next-4da646a12b2e0ba41483ebf5a98cd74907a22e10", | ||
"version": "0.0.0-next-4eaf0370d44a91ba9c196f41774c1b6b61b5029c", | ||
"repository": { | ||
@@ -52,10 +52,10 @@ "type": "git", | ||
"eventemitter3": "^4.0.0", | ||
"hadron-type-checker": "0.0.0-next-4da646a12b2e0ba41483ebf5a98cd74907a22e10", | ||
"hadron-type-checker": "0.0.0-next-4eaf0370d44a91ba9c196f41774c1b6b61b5029c", | ||
"lodash": "^4.17.21" | ||
}, | ||
"devDependencies": { | ||
"@mongodb-js/eslint-config-compass": "0.0.0-next-4da646a12b2e0ba41483ebf5a98cd74907a22e10", | ||
"@mongodb-js/mocha-config-compass": "0.0.0-next-4da646a12b2e0ba41483ebf5a98cd74907a22e10", | ||
"@mongodb-js/prettier-config-compass": "0.0.0-next-4da646a12b2e0ba41483ebf5a98cd74907a22e10", | ||
"@mongodb-js/tsconfig-compass": "0.0.0-next-4da646a12b2e0ba41483ebf5a98cd74907a22e10", | ||
"@mongodb-js/eslint-config-compass": "0.0.0-next-4eaf0370d44a91ba9c196f41774c1b6b61b5029c", | ||
"@mongodb-js/mocha-config-compass": "0.0.0-next-4eaf0370d44a91ba9c196f41774c1b6b61b5029c", | ||
"@mongodb-js/prettier-config-compass": "0.0.0-next-4eaf0370d44a91ba9c196f41774c1b6b61b5029c", | ||
"@mongodb-js/tsconfig-compass": "0.0.0-next-4eaf0370d44a91ba9c196f41774c1b6b61b5029c", | ||
"chai": "^4.2.0", | ||
@@ -70,3 +70,3 @@ "depcheck": "^1.4.1", | ||
}, | ||
"gitHead": "4da646a12b2e0ba41483ebf5a98cd74907a22e10" | ||
"gitHead": "4eaf0370d44a91ba9c196f41774c1b6b61b5029c" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
175532
2060