Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1254 Create Artifact Record for New Project #1303

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
7 changes: 5 additions & 2 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ jobs:
deploy-server:
name: 🚀 Deploy server
needs: test-client
environment:
environment:
name: production
url: https://applicants-api.nycplanningdigital.com
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: server
- name: 'Install Heroku CLI'
run: curl https://cli-assets.heroku.com/install.sh | sh
- uses: akhileshns/[email protected]
name: Deploy server to Heroku
with:
Expand Down Expand Up @@ -75,6 +77,7 @@ jobs:
HD_PAYMENT_IP_RANGE: ${{ secrets.PAYMENT_IP_RANGE }}
HD_PAYMENT_STEP1_URL: ${{ secrets.PAYMENT_STEP1_URL }}
HD_RER_FILETYPE_UUID: ${{ secrets.RER_FILETYPE_UUID }}
HD_LETTER_FILETYPE_UUID: ${{ secrets.LETTER_FILETYPE_UUID }}
HD_SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
HD_SHAREPOINT_CLIENT_ID: ${{ secrets.SHAREPOINT_CLIENT_ID }}
HD_SHAREPOINT_CLIENT_SECRET: ${{ secrets.SHAREPOINT_CLIENT_SECRET }}
Expand Down Expand Up @@ -107,7 +110,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 12.x
- name: Install application dependencies
- name: Install application dependencies
working-directory: client
run: yarn install --immutable --immutable-cache --check-cache
- name: Build client
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ jobs:
- uses: actions/checkout@v4
with:
sparse-checkout: server
- name: 'Install Heroku CLI'
run: curl https://cli-assets.heroku.com/install.sh | sh
- uses: akhileshns/[email protected]
name: Deploy server to Heroku
with:
Expand Down Expand Up @@ -72,6 +74,7 @@ jobs:
HD_PAYMENT_IP_RANGE: ${{ secrets.PAYMENT_IP_RANGE }}
HD_PAYMENT_STEP1_URL: ${{ secrets.PAYMENT_STEP1_URL }}
HD_RER_FILETYPE_UUID: ${{ secrets.RER_FILETYPE_UUID }}
HD_LETTER_FILETYPE_UUID: ${{ secrets.LETTER_FILETYPE_UUID }}
HD_SHAREPOINT_CLIENT_ID: ${{ secrets.SHAREPOINT_CLIENT_ID }}
HD_SHAREPOINT_CLIENT_SECRET: ${{ secrets.SHAREPOINT_CLIENT_SECRET }}
HD_SHAREPOINT_CRM_SITE: ${{ secrets.SHAREPOINT_CRM_SITE }}
Expand Down Expand Up @@ -102,7 +105,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 12.x
- name: Install application dependencies
- name: Install application dependencies
working-directory: client
run: yarn install --immutable --immutable-cache --check-cache
- name: Build client
Expand All @@ -119,4 +122,3 @@ jobs:
--site ${{secrets.NETLIFY_SITE_ID}} \
--auth ${{secrets.NETLIFY_AUTH_TOKEN}} \
--message "${{ github.event.head_commit.message }}"

5 changes: 4 additions & 1 deletion .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ jobs:
with:
ref: 'main'
sparse-checkout: server
- name: 'Install Heroku CLI'
run: curl https://cli-assets.heroku.com/install.sh | sh
- uses: akhileshns/[email protected]
name: Deploy server to Heroku
with:
Expand All @@ -63,6 +65,7 @@ jobs:
HD_NYCID_TOKEN_SECRET: ${{ secrets.NYCID_TOKEN_SECRET }}
HD_PAPERTRAIL_API_TOKEN: ${{ secrets.PAPERTRAIL_API_TOKEN }}
HD_RER_FILETYPE_UUID: ${{ secrets.RER_FILETYPE_UUID }}
HD_LETTER_FILETYPE_UUID: ${{ secrets.LETTER_FILETYPE_UUID }}
HD_SHAREPOINT_CLIENT_ID: ${{ secrets.SHAREPOINT_CLIENT_ID }}
HD_SHAREPOINT_CLIENT_SECRET: ${{ secrets.SHAREPOINT_CLIENT_SECRET }}
HD_SHAREPOINT_CRM_SITE: ${{ secrets.SHAREPOINT_CRM_SITE }}
Expand Down Expand Up @@ -94,7 +97,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 12.x
- name: Install application dependencies
- name: Install application dependencies
working-directory: client
run: yarn install
- name: Build client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
@attribute='documents'
@validation={{@form.errors.documents.validation}}
/>

<Packages::Attachments
@package={{@form.data}}
@fileManager={{@model.fileManager}}
Expand Down
34 changes: 24 additions & 10 deletions client/app/components/projects/new.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,42 @@
@selectedApplicantType={{this.selectedApplicantType}}
@applicantOptions={{this.applicantOptions}}
/>

<Projects::ProjectsNewAddContacts
@form={{saveableProjectsNewForm}} />

<Projects::ProjectsNewProjectDescription
@form={{saveableProjectsNewForm}} />

<Projects::ProjectsNewAttachedDocuments
@artifact={{saveableProjectsNewForm.data}}
@form={{saveableProjectsNewForm}}
@model={{@package}} />
</div>
<div class="cell large-4 sticky-sidebar">
<saveableProjectsNewForm.PageNav>
<saveableProjectsNewForm.SubmitButton @isEnabled={{saveableProjectsNewForm.isSubmittable}} data-test-save-button />
</saveableProjectsNewForm.PageNav>
<Messages::Assistance class="large-margin-top" />
<saveableProjectsNewForm.ConfirmationModal @action={{component saveableProjectsNewForm.SubmitButton
isEnabled=saveableProjectsNewForm.isSubmittable onClick=this.submitProject class="no-margin" }}
<saveableProjectsNewForm.ConfirmationModal @action={{component saveableProjectsNewForm.SubmitButton onClick=this.submitProject class="no-margin" }}
disabled={{or (not saveableProjectsNewForm.isSubmittable) this.submissionError this.isSubmitting}}
@continueButtonTitle="Continue Editing" data-test-confirm-submit-button={{true}}>
<h6>Confirm New Project Submission</h6>
<p class="header-large medium-margin-top small-margin-bottom">
Are you sure?
</p>
<p>
Before submitting, ensure that your answers are accurate and complete, and that necessary attachments (including
the
signature form) have been uploaded.
</p>
{{#if this.submissionError}}
<div class="grid-x medium-padding-top medium-padding-bottom">
<p class="header-large medium-marin-top small-margin-bottom">Error while creating project. Lorem Ipsum.....</p>
</div>
{{else}}
<p class="header-large medium-margin-top small-margin-bottom">
Are you sure?
</p>
<p>
Before submitting, ensure that your answers are accurate and complete, and that necessary attachments have been
uploaded. If NYC Planning does not receive enough accurate information to provide guidance, the Lead Planner will
notify you and request that this form be resubmitted with necessary materials, corrections, or
clarifications.
</p>
{{/if}}
</saveableProjectsNewForm.ConfirmationModal>
</div>
</div>
Expand Down
46 changes: 44 additions & 2 deletions client/app/components/projects/new.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { inject as service } from '@ember/service';
import SubmittableProjectsNewForm from '../../validations/submittable-projects-new-form';
import { optionset } from '../../helpers/optionset';
import config from '../../config/environment';
import validateFileUpload from '../../validators/validate-file-presence';

export default class ProjectsNewFormComponent extends Component {
validations = {
SubmittableProjectsNewForm,
};

@tracked
submissionError = false;

@tracked
isSubmitting = false;

requestCounter = 0;

@service
router;

Expand All @@ -26,6 +36,13 @@ export default class ProjectsNewFormComponent extends Component {

@action
async submitProject() {
this.submissionError = false;
if (this.isSubmitting) return;
this.isSubmitting = true;
const requestStartTime = Date.now();
this.requestCounter++;
console.log(`LOGGER: [Total Requests Made in the client controller] ${this.requestCounter}`);

const primaryContactInput = {
first: this.args.package.primaryContactFirstName,
last: this.args.package.primaryContactLastName,
Expand All @@ -42,6 +59,17 @@ export default class ProjectsNewFormComponent extends Component {

const contactInputs = [primaryContactInput, applicantInput];

const validationResult = validateFileUpload(
{
message: 'Please upload at least one file before submitting.',
},
)('documents', this.args.package.documents);

if (validationResult !== true) {
this.errorMessage = validationResult;
return;
}

try {
const contactPromises = contactInputs.map((contact) => this.store.queryRecord('contact', {
email: contact.email,
Expand Down Expand Up @@ -96,17 +124,31 @@ export default class ProjectsNewFormComponent extends Component {
dcpApplicanttype: this.args.package.applicantType.code,
dcpProjectbrief: this.args.package.projectBrief,
_dcpApplicantadministratorCustomerValue:
verifiedPrimaryContact.id,
verifiedPrimaryContact.id,
_dcpApplicantCustomerValue: verifiedApplicant.id,
},
},
}),
});
const { data: project } = await response.json();
this.router.transitionTo('project', project.id);
const requestEndTime = Date.now();
console.debug(`LOGGER: POST request in the client controller to took ${requestEndTime - requestStartTime} ms`);
console.debug('response in client controller: ', response, 'response status: ', response.status);

const artifactsId = project.attributes['dcp-artifactsid'];
if (artifactsId === undefined) {
throw new Error('failed to create project with artifact');
}

await this.args.package.saveAttachedFiles(artifactsId);

this.router.transitionTo('projects');
} catch {
this.submissionError = true;
/* eslint-disable-next-line no-console */
console.error('Error while creating project');
} finally {
this.isSubmitting = false;
}
}
}
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> &nbsp;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}}
Loading
Loading