-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' of https://github.com/kanselarij-vlaandere…
…n/kaleidos-frontend into DES/enhancement/#732-vlc-refactor
- Loading branch information
Showing
12 changed files
with
178 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
app/components/publications/publication/documents/documents-upload-modal.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<WebComponents::AuModal @resized={{this.isExpanded}}> | ||
<WebComponents::AuModal::Header | ||
@resizeable={{true}} | ||
@title={{t "documents-add"}} | ||
@changeIcon={{this.isExpanded}} | ||
@toggleSize={{this.toggleSize}} | ||
@closeModal={{perform this.cancelUploadPieces}} | ||
/> | ||
<WebComponents::AuModal::Body> | ||
{{#if this.savePieces.isRunning}} | ||
<WebComponents::VlLoader @text={{t "documents-loading-text"}} /> | ||
{{else}} | ||
<WebComponents::AuFileUploader | ||
@fullHeight={{eq this.newPieces.length 0}} | ||
@multipleFiles={{true}} | ||
@uploadedFileAction={{this.uploadPiece}} | ||
/> | ||
{{! TODO vervangen met correct design (nog in flux), au css en componenten }} | ||
<div class="upload-container"> | ||
{{#each this.newPieces as |piece|}} | ||
<Documents::UploadedDocument | ||
@piece={{piece}} | ||
@allowDocumentContainerEdit={{true}} | ||
@onDelete={{perform this.deleteUploadedPiece piece}} | ||
/> | ||
{{/each}} | ||
</div> | ||
{{/if}} | ||
</WebComponents::AuModal::Body> | ||
<WebComponents::AuModal::Footer | ||
@cancelModal={{perform this.cancelUploadPieces}} | ||
> | ||
{{#if this.savePieces.isRunning}} | ||
<Utils::SimpleSpinner /> | ||
{{else}} | ||
<WebComponents::AuButton | ||
data-test-au-modal-footer-save | ||
@skin="primary" | ||
@disabled={{eq this.newPieces.length 0}} | ||
{{on "click" (perform this.savePieces)}} | ||
> | ||
{{t "documents-add"}} | ||
</WebComponents::AuButton> | ||
{{/if}} | ||
</WebComponents::AuModal::Footer> | ||
</WebComponents::AuModal> |
84 changes: 84 additions & 0 deletions
84
app/components/publications/publication/documents/documents-upload-modal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import Component from '@glimmer/component'; | ||
import { action } from '@ember/object'; | ||
import { inject } from '@ember/service'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { task } from 'ember-concurrency-decorators'; | ||
import { all } from 'ember-concurrency'; | ||
|
||
export default class PublicationsPublicationDocumentsDocumentsUploadModalComponent extends Component { | ||
@inject store; | ||
|
||
@tracked isExpanded = false; | ||
@tracked newPieces = []; | ||
|
||
@action | ||
toggleSize() { | ||
this.isExpanded = !this.isExpanded; | ||
} | ||
|
||
@action | ||
uploadPiece(file) { | ||
const now = new Date(); | ||
const documentContainer = this.store.createRecord('document-container', { | ||
created: now, | ||
}); | ||
const piece = this.store.createRecord('piece', { | ||
created: now, | ||
modified: now, | ||
file: file, | ||
accessLevel: this.defaultAccessLevel, | ||
confidential: false, | ||
name: file.filenameWithoutExtension, | ||
documentContainer: documentContainer, | ||
}); | ||
this.newPieces.pushObject(piece); | ||
} | ||
|
||
@task | ||
*cancelUploadPieces() { | ||
const deleteTasks = this.newPieces.map((piece) => this.deleteUploadedPiece.perform(piece)); | ||
yield all(deleteTasks); | ||
this.args.onCancel(); | ||
} | ||
|
||
@task | ||
*deleteUploadedPiece(piece) { | ||
const file = yield piece.file; | ||
yield file.destroyRecord(); | ||
this.newPieces.removeObject(piece); | ||
const documentContainer = yield piece.documentContainer; | ||
yield documentContainer.destroyRecord(); | ||
yield piece.destroyRecord(); | ||
} | ||
|
||
@action | ||
cancelDeleteExistingPiece() { | ||
this.pieceToDelete = null; | ||
this.isVerifyingDelete = false; | ||
} | ||
|
||
@task | ||
*savePieces() { | ||
const savePromises = this.newPieces.map(async(piece) => { | ||
try { | ||
await this.savePiece.perform(piece); | ||
} catch (error) { | ||
await this.deleteUploadedPiece.perform(piece); | ||
throw error; | ||
} | ||
}); | ||
yield all(savePromises); | ||
yield this.args.onSaveTask.perform(this.newPieces); | ||
this.newPieces = []; | ||
} | ||
|
||
/** | ||
* Save a new document container and the piece it wraps | ||
*/ | ||
@task | ||
*savePiece(piece) { | ||
const documentContainer = yield piece.documentContainer; | ||
yield documentContainer.save(); | ||
yield piece.save(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.