-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1254 Create Artifact Record with Project Creation
- Added artifact creation endpoint and returning artifact id from server to client - Create a form through which users may submit and attach documents (client) - Added validation for required submission of project documents Co-authored-by: horatio <[email protected]>
- Loading branch information
1 parent
fe9fbbf
commit 1cea764
Showing
20 changed files
with
533 additions
and
72 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
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
23 changes: 23 additions & 0 deletions
23
client/app/components/projects/projects-new-attached-documents.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,23 @@ | ||
{{#let @form as |form|}} | ||
<@form.Section @title='Attached Documents'> | ||
<p> | ||
Please attach the required items listed on the | ||
<Ui::ExternalLink @href="https://www.nyc.gov/assets/planning/download/pdf/applicants/applicant-portal/interest_checklist.pdf"> | ||
Informational Interest Meeting Checklist | ||
</Ui::ExternalLink> in at least one PDF document. The maximum | ||
size for a document is 50MB. | ||
</p> | ||
|
||
<SaveableForm::FieldValidationMessage | ||
@attribute='documents' | ||
@validation={{@form.errors.documents.validation}} /> | ||
|
||
<Projects::ProjectsNewAttachments | ||
@package={{@form.data}} | ||
@artifact={{@artifact}} | ||
@fileManager={{@model.fileManager}} | ||
@attribute="documents" | ||
data-test-section='attachments' /> | ||
</@form.Section> | ||
|
||
{{/let}} |
133 changes: 133 additions & 0 deletions
133
client/app/components/projects/projects-new-attachments.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,133 @@ | ||
<div ...attributes> | ||
<fieldset class="fieldset"> | ||
<Ui::Legend> | ||
Attachments | ||
<Ui::RequiredAsterisk /> | ||
</Ui::Legend> | ||
|
||
<ul class="no-bullet"> | ||
{{#each @fileManager.existingFiles as |file idx|}} | ||
<li class="slide-in-bottom"> | ||
<div class="grid-x"> | ||
<div class="cell auto"> | ||
<a | ||
href={{concat (get-env-variable 'host') '/documents' file.serverRelativeUrl}} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
data-test-document-name={{idx}} | ||
> | ||
{{file.name}} | ||
</a> | ||
</div> | ||
<div class="cell shrink medium-padding-left"> | ||
<small> | ||
{{file.timeCreated}} | ||
</small> | ||
</div> | ||
<div class="cell shrink medium-padding-left"> | ||
<button | ||
type="button" | ||
class="text-red-dark" | ||
{{on "click" (fn this.markFileForDeletion file)}} | ||
data-test-delete-file-button={{idx}} | ||
> | ||
<FaIcon @icon="times" @prefix="fas" @fixedWidth={{true}} /> | ||
</button> | ||
</div> | ||
</div> | ||
</li> | ||
{{/each}} | ||
</ul> | ||
|
||
{{#if (or @fileManager.filesToDelete @fileManager.filesToUpload.files)}} | ||
{{#if @fileManager.existingFiles}} | ||
<hr> | ||
{{/if}} | ||
|
||
<h6 class="medium-margin-bottom slide-in-top"> | ||
To be | ||
{{if @fileManager.filesToUpload.files 'uploaded'}} | ||
{{if (and @fileManager.filesToDelete @fileManager.filesToUpload.files) '/'}} | ||
{{if @fileManager.filesToDelete 'deleted'}} | ||
when you save the project: | ||
</h6> | ||
{{/if}} | ||
|
||
<ul class="no-bullet"> | ||
{{#each @fileManager.filesToDelete as |file idx|}} | ||
<li class="slide-in-top"> | ||
<div class="grid-x"> | ||
<div class="cell auto"> | ||
<b | ||
data-test-document-to-be-deleted-name={{idx}} | ||
> | ||
{{file.name}} | ||
</b> | ||
</div> | ||
<div class="cell shrink medium-padding-left"> | ||
<small> | ||
TO BE DELETED | ||
</small> | ||
</div> | ||
<div class="cell shrink medium-padding-left"> | ||
<button | ||
type="button" | ||
{{on "click" (fn this.unmarkFileForDeletion file)}} | ||
data-test-undo-delete-file-button={{idx}} | ||
> | ||
<FaIcon @icon="undo" @prefix="fas" @fixedWidth={{true}} /> | ||
</button> | ||
</div> | ||
</div> | ||
</li> | ||
{{/each}} | ||
</ul> | ||
|
||
<ul class="no-bullet"> | ||
{{#each @fileManager.filesToUpload.files as |file idx|}} | ||
<li class="slide-in-top"> | ||
<div class="grid-x"> | ||
<div class="cell auto"> | ||
<b | ||
data-test-document-to-be-uploaded-name={{idx}} | ||
> | ||
{{file.name}} | ||
</b> | ||
</div> | ||
<div class="cell shrink medium-padding-left"> | ||
<small> | ||
TO BE ADDED | ||
</small> | ||
</div> | ||
<div class="cell shrink medium-padding-left"> | ||
<button | ||
type="button" | ||
class="text-red-dark" | ||
{{on "click" (fn this.deselectFileForUpload file)}} | ||
data-test-deselect-file-button={{idx}} | ||
> | ||
<FaIcon @icon="times" @prefix="fas" @fixedWidth={{true}} /> | ||
</button> | ||
</div> | ||
</div> | ||
</li> | ||
{{/each}} | ||
</ul> | ||
|
||
<FileUpload | ||
id={{concat "FileUploader" @artifact.id}} | ||
@name={{concat "artifact" @artifact.id}} | ||
@accept='*/*' | ||
@multiple={{true}} | ||
@onfileadd={{this.trackFileForUpload}} | ||
class="button secondary expanded" | ||
> | ||
<FaIcon @icon="upload" @prefix="fas" /> | ||
Choose Files | ||
</FileUpload> | ||
|
||
<p class="text-small tiny-margin-bottom text-dark-gray"> | ||
The size limit for each file is 50 MB. You can upload up to 1 GB of files. | ||
</p> | ||
</fieldset> | ||
</div> |
63 changes: 63 additions & 0 deletions
63
client/app/components/projects/projects-new-attachments.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,63 @@ | ||
import Component from '@glimmer/component'; | ||
import { action } from '@ember/object'; | ||
import validateFileUpload from '../../validators/validate-file-presence'; | ||
|
||
/** | ||
* This component wires a fileManager to the attachments UI. | ||
* @param {Artifact Model} artifact | ||
*/ | ||
export default class ProjectsNewAttachmentsComponent extends Component { | ||
get fileManager() { | ||
// should be an instance of FileManager | ||
return this.args.fileManager; | ||
} | ||
|
||
@action | ||
markFileForDeletion(file) { | ||
this.fileManager.markFileForDeletion(file); | ||
|
||
this.args.package.documents = this.fileManager.existingFiles; | ||
} | ||
|
||
@action | ||
unmarkFileForDeletion(file) { | ||
this.fileManager.unMarkFileForDeletion(file); | ||
} | ||
|
||
// This action doesn't perform any file selection. | ||
// That part is automatically handled by the | ||
// ember-file-upload addon. | ||
// Here we manually increment the number of files to | ||
// upload to update the fileManager isDirty state. | ||
@action | ||
trackFileForUpload() { | ||
this.fileManager.trackFileForUpload(); | ||
this.args.package.documents = [ | ||
...this.args.package.documents, | ||
...this.fileManager.filesToUpload.files, | ||
]; | ||
} | ||
|
||
@action | ||
deselectFileForUpload(file) { | ||
this.fileManager.deselectFileForUpload(file); | ||
|
||
this.args.package.documents = this.args.package.documents.filter( | ||
(document) => document !== file, | ||
); | ||
} | ||
|
||
@action | ||
validateFilePresence() { | ||
const validationResult = validateFileUpload({ message: 'One or more document uploads is required.' })( | ||
'documents', | ||
this.fileManager.filesToUpload.files, | ||
); | ||
|
||
if (validationResult !== true) { | ||
this.errorMessage = validationResult; | ||
} else { | ||
this.errorMessage = null; | ||
} | ||
} | ||
} |
Oops, something went wrong.