diff --git a/client/app/components/projects/new.js b/client/app/components/projects/new.js index 9ae1df93..20ad8420 100644 --- a/client/app/components/projects/new.js +++ b/client/app/components/projects/new.js @@ -35,6 +35,8 @@ export default class ProjectsNewFormComponent extends Component { applicantType: this.args.package.applicantType.code, }; + console.log("projectInformation", projectInformation); + const primaryContactInput = { first: this.args.package.primaryContactFirstName, last: this.args.package.primaryContactLastName, @@ -51,6 +53,16 @@ export default class ProjectsNewFormComponent extends Component { role: 'applicant', }; + let newProject = this.store.createRecord("project", { + dcpProjectname: projectInformation.projectName, + dcpBorough: projectInformation.borough, + dcpApplicanttype: projectInformation.applicantType, + }); + // return projectModel.save(); + + console.log('new project?', newProject); + console.log('new project?', newProject.changedAttributes()); + const contactInputs = [primaryContactInput, applicantInput]; try { @@ -78,21 +90,16 @@ export default class ProjectsNewFormComponent extends Component { return contact; }); - const saveProjectInformation = () => { - const projectModel = this.store.createRecord('project', { - dcpProjectName: projectInformation.projectName, - dcpBorough: projectInformation.borough, - dcoApplicantType: projectInformation.applicantType, - }); - return projectModel.save(); - }; - - await Promise.all( - [ - verifiedContactPromises, - saveProjectInformation, - ], - ) + // const saveProjectInformation = () => { + // const projectModel = this.store.createRecord('project', { + // dcpProjectName: projectInformation.projectName, + // dcpBorough: projectInformation.borough, + // dcoApplicantType: projectInformation.applicantType, + // }); + // return projectModel.save(); + // }; + + await Promise.all(verifiedContactPromises) .then( await this.args.package.submit(), ); diff --git a/client/app/models/project.js b/client/app/models/project.js index dcf7ae07..31fa9caf 100644 --- a/client/app/models/project.js +++ b/client/app/models/project.js @@ -3,7 +3,7 @@ import { optionset } from '../helpers/optionset'; export default class ProjectModel extends Model { // The human-readable, descriptive name. - // e.g. "Marcus Garvey Blvd Project" + // e.g. 'Marcus Garvey Blvd Project' @attr dcpProjectname; // The CRM Project 5-letter ID. @@ -68,6 +68,37 @@ export default class ProjectModel extends Model { @attr('number') dcpNewcommunityfacilitysqft; + // new project attributes + + // either 'Other Public entity' or 'Private' + // either 717170000 or 717170002 + @attr('string') + dcpApplicanttype; + + @attr('string') + primaryContactFirstName; + + @attr('string') + primaryContactLastName; + + @attr('string') + primaryContactEmail; + + @attr('string') + primaryContactPhone; + + @attr('string') + applicantFirstName; + + @attr('string') + applicantLastName; + + @attr('string') + applicantEmail; + + @attr('string') + applicantPhone; + // We assume there's only one. If there's >1 in crm, the backend // should return the first one. @belongsTo('artifact', { async: false }) @@ -85,18 +116,24 @@ export default class ProjectModel extends Model { @hasMany('milestone', { async: false }) milestones; - get isDirty () { + get isDirty() { return this.hasDirtyAttributes || (this.artifact && this.artifact.isDirty); } get publicStatusGeneralPublicProject() { - const isGeneralPublic = this.dcpVisibility === optionset(['project', 'dcpVisibility', 'code', 'GENERAL_PUBLIC']); + const isGeneralPublic = + this.dcpVisibility === + optionset(['project', 'dcpVisibility', 'code', 'GENERAL_PUBLIC']); return this.dcpPublicstatus && isGeneralPublic; } get pasPackages() { const pasPackages = this.packages - .filter((projectPackage) => projectPackage.dcpPackagetype === optionset(['package', 'dcpPackagetype', 'code', 'PAS_PACKAGE'])) + .filter( + (projectPackage) => + projectPackage.dcpPackagetype === + optionset(['package', 'dcpPackagetype', 'code', 'PAS_PACKAGE']) + ) .sortBy('dcpPackageversion') .reverse(); @@ -105,7 +142,11 @@ export default class ProjectModel extends Model { get rwcdsPackages() { const rwcdsPackages = this.packages - .filter((projectPackage) => projectPackage.dcpPackagetype === optionset(['package', 'dcpPackagetype', 'code', 'RWCDS'])) + .filter( + (projectPackage) => + projectPackage.dcpPackagetype === + optionset(['package', 'dcpPackagetype', 'code', 'RWCDS']) + ) .sortBy('dcpPackageversion') .reverse(); @@ -124,7 +165,11 @@ export default class ProjectModel extends Model { get draftLandusePackages() { const landusePackages = this.packages - .filter((projectPackage) => projectPackage.dcpPackagetype === optionset(['package', 'dcpPackagetype', 'code', 'DRAFT_LU_PACKAGE'])) + .filter( + (projectPackage) => + projectPackage.dcpPackagetype === + optionset(['package', 'dcpPackagetype', 'code', 'DRAFT_LU_PACKAGE']) + ) .sortBy('dcpPackageversion') .reverse(); @@ -133,7 +178,11 @@ export default class ProjectModel extends Model { get filedLandusePackages() { const landusePackages = this.packages - .filter((projectPackage) => projectPackage.dcpPackagetype === optionset(['package', 'dcpPackagetype', 'code', 'FILED_LU_PACKAGE'])) + .filter( + (projectPackage) => + projectPackage.dcpPackagetype === + optionset(['package', 'dcpPackagetype', 'code', 'FILED_LU_PACKAGE']) + ) .sortBy('dcpPackageversion') .reverse(); @@ -142,23 +191,28 @@ export default class ProjectModel extends Model { get postCertLUPackages() { return this.packages - .filter((projectPackage) => projectPackage.dcpPackagetype === optionset(['package', 'dcpPackagetype', 'code', 'POST_CERT_LU'])) + .filter( + (projectPackage) => + projectPackage.dcpPackagetype === + optionset(['package', 'dcpPackagetype', 'code', 'POST_CERT_LU']) + ) .sortBy('dcpPackageversion') .reverse(); } get easPackages() { - const easPackages = [ - ...this.filedEasPackages, - ...this.draftEasPackages, - ]; + const easPackages = [...this.filedEasPackages, ...this.draftEasPackages]; return easPackages; } get draftEasPackages() { const easPackages = this.packages - .filter((projectPackage) => projectPackage.dcpPackagetype === optionset(['package', 'dcpPackagetype', 'code', 'DRAFT_EAS'])) + .filter( + (projectPackage) => + projectPackage.dcpPackagetype === + optionset(['package', 'dcpPackagetype', 'code', 'DRAFT_EAS']) + ) .sortBy('dcpPackageversion') .reverse(); @@ -167,7 +221,11 @@ export default class ProjectModel extends Model { get filedEasPackages() { const easPackages = this.packages - .filter((projectPackage) => projectPackage.dcpPackagetype === optionset(['package', 'dcpPackagetype', 'code', 'FILED_EAS'])) + .filter( + (projectPackage) => + projectPackage.dcpPackagetype === + optionset(['package', 'dcpPackagetype', 'code', 'FILED_EAS']) + ) .sortBy('dcpPackageversion') .reverse(); @@ -176,7 +234,16 @@ export default class ProjectModel extends Model { get scopeOfWorkDraftPackages() { const scopeOfWorkDraftPackages = this.packages - .filter((projectPackage) => projectPackage.dcpPackagetype === optionset(['package', 'dcpPackagetype', 'code', 'DRAFT_SCOPE_OF_WORK'])) + .filter( + (projectPackage) => + projectPackage.dcpPackagetype === + optionset([ + 'package', + 'dcpPackagetype', + 'code', + 'DRAFT_SCOPE_OF_WORK', + ]) + ) .sortBy('dcpPackageversion') .reverse(); @@ -184,19 +251,18 @@ export default class ProjectModel extends Model { } get eisPackages() { - const eisPackages = [ - ...this.feisPackages, - ...this.deisPackages, - ]; + const eisPackages = [...this.feisPackages, ...this.deisPackages]; return eisPackages; } get deisPackages() { const eisPackages = this.packages - .filter((projectPackage) => projectPackage.dcpPackagetype === optionset( - ['package', 'dcpPackagetype', 'code', 'PDEIS'], - )) + .filter( + (projectPackage) => + projectPackage.dcpPackagetype === + optionset(['package', 'dcpPackagetype', 'code', 'PDEIS']) + ) .sortBy('dcpPackageversion') .reverse(); @@ -205,9 +271,11 @@ export default class ProjectModel extends Model { get feisPackages() { const eisPackages = this.packages - .filter((projectPackage) => projectPackage.dcpPackagetype === optionset( - ['package', 'dcpPackagetype', 'code', 'EIS'], - )) + .filter( + (projectPackage) => + projectPackage.dcpPackagetype === + optionset(['package', 'dcpPackagetype', 'code', 'EIS']) + ) .sortBy('dcpPackageversion') .reverse(); @@ -216,9 +284,11 @@ export default class ProjectModel extends Model { get technicalMemoPackages() { const technicalMemoPackages = this.packages - .filter((projectPackage) => projectPackage.dcpPackagetype === optionset( - ['package', 'dcpPackagetype', 'code', 'TECHNICAL_MEMO'], - )) + .filter( + (projectPackage) => + projectPackage.dcpPackagetype === + optionset(['package', 'dcpPackagetype', 'code', 'TECHNICAL_MEMO']) + ) .sortBy('dcpPackageversion') .reverse(); @@ -227,9 +297,11 @@ export default class ProjectModel extends Model { get workingPackages() { return this.packages - .filter((projectPackage) => projectPackage.dcpPackagetype === optionset( - ['package', 'dcpPackagetype', 'code', 'WORKING_PACKAGE'], - )) + .filter( + (projectPackage) => + projectPackage.dcpPackagetype === + optionset(['package', 'dcpPackagetype', 'code', 'WORKING_PACKAGE']) + ) .sortBy('dcpPackageversion') .reverse(); }