From 28804ceba1c335f0185d9c663309034a648a8dff Mon Sep 17 00:00:00 2001 From: isUnknown Date: Thu, 23 Jan 2025 12:23:14 +0100 Subject: [PATCH] save DTL --- public/site/blueprints/pages/client-brief.yml | 1 + .../site/blueprints/tabs/design-to-light.yml | 68 +++- public/site/plugins/helpers/index.php | 1 + public/site/templates/project.json.php | 290 +++++++++--------- src/App.vue | 7 +- src/components/design-to-light/DTLButton.vue | 26 +- src/components/design-to-light/DTLPanel.vue | 55 +++- 7 files changed, 267 insertions(+), 181 deletions(-) diff --git a/public/site/blueprints/pages/client-brief.yml b/public/site/blueprints/pages/client-brief.yml index 2e900df..c66cd17 100644 --- a/public/site/blueprints/pages/client-brief.yml +++ b/public/site/blueprints/pages/client-brief.yml @@ -28,6 +28,7 @@ tabs: label: PDF type: files template: pdf + upload: pdf multiple: false description: type: textarea diff --git a/public/site/blueprints/tabs/design-to-light.yml b/public/site/blueprints/tabs/design-to-light.yml index 963d11a..efb3cc6 100644 --- a/public/site/blueprints/tabs/design-to-light.yml +++ b/public/site/blueprints/tabs/design-to-light.yml @@ -2,18 +2,34 @@ designToLight: label: Design to light icon: leaf -columns: - - width: 2/10 - fields: - isDTLEnabled: - label: Actif - type: toggle - default: false - - width: 8/10 +fields: + isDTLEnabled: + label: Actif + type: toggle + default: false + width: 2/10 + dtlProposals: + label: Propositions + type: structure + when: + isDTLEnabled: true + help: | + **La première proposition correspond au projet initial. Les propositions suivantes constituent des alternatives.** + Pour déplacer une proposition, survolez son index puis cliquez-glissez la poignée ⁝⁝ + width: 8/10 + columns: + DTLProposalLocation: + label: Localisation + width: 1/2 + DTLGrade: + label: Note globale + width: 1/2 + after: / 10 + fields: DTLTargetHeadline: type: headline - label: La proposition Design to light + label: La proposition DTLProposalLocation: label: Localisation @@ -24,8 +40,6 @@ columns: industrialIdeation: Idéation industrielle virtualSampleDynamicTrack: Échantillon virtuel - piste dynamique virtualSampleStaticTrack: Échantillon virtuel - piste statique - when: - isDTLEnabled: true width: 1/2 DTLproposal: @@ -76,10 +90,38 @@ columns: type: range min: 0 max: 10 + default: 5 tooltip: after: / 10 - when: - isDTLEnabled: true + + positionHeadline: + type: headline + label: Positionnement + + DTLComplexityGrade: + label: Complexité + type: range + before: Complexe + min: -5 + max: 5 + after: Sobre + default: 0 + help: Axe horizontal (X) du graph + width: 1/2 + DTLWeightGrade: + label: Poids + type: range + before: Lourd + min: -5 + max: 5 + after: Léger + default: 0 + help: Axe vertical (Y) du graph + width: 1/2 + + indicatorsHeadline: + type: headline + label: Indicateurs DTLDesignGrade: label: Design global diff --git a/public/site/plugins/helpers/index.php b/public/site/plugins/helpers/index.php index d460123..776224c 100644 --- a/public/site/plugins/helpers/index.php +++ b/public/site/plugins/helpers/index.php @@ -1,6 +1,7 @@ $file->modified('YYYY-MM-dd'), 'url' => $file->thumb([ diff --git a/public/site/templates/project.json.php b/public/site/templates/project.json.php index 6988c1e..39a1c4f 100644 --- a/public/site/templates/project.json.php +++ b/public/site/templates/project.json.php @@ -1,160 +1,154 @@ = 0 && $numberedGrade < 3) { - return [ - "letter" => "D", + $gradeMapping = [ + [0, 3, "D", "Assez lourd", "Allègement du flacon recommandé"], + [3, 6, "C", "Assez lourd", "Allègement du flacon recommandé"], + [6, 8, "B", "Assez lourd", "Allègement du flacon recommandé"], + [8, 10, "A", "Léger", "Conception optimisée"], + ]; + + foreach ($gradeMapping as [$min, $max, $letter, $mention, $comment]) { + if ($numberedGrade >= $min && $numberedGrade < $max) { + return [ + "letter" => $letter, + "number" => $numberedGrade, + "mention" => $mention, + "comment" => $comment, + ]; + } + } + + return [ + "letter" => "", "number" => $numberedGrade, - "mention" => "Assez lourd", - "comment" => "Allègement du flacon recommandé" - ]; - } - if ($numberedGrade >= 3 && $numberedGrade < 6) { - return [ - "letter" => "C", - "number" => $numberedGrade, - "mention" => "Assez lourd", - "comment" => "Allègement du flacon recommandé" - ]; - } - if ($numberedGrade >= 6 && $numberedGrade < 8) { - return [ - "letter" => "B", - "number" => $numberedGrade, - "mention" => "Assez lourd", - "comment" => "Allègement du flacon recommandé" - ]; - } - if ($numberedGrade >= 8 && $numberedGrade <= 10) { - return [ - "letter" => "A", - "number" => $numberedGrade, - "mention" => "Assez lourd", - "comment" => "Allègement du flacon recommandé" - ]; - } - return [ - "letter" => "", - "number" => $numberedGrade, - "mention" => "Assez lourd", - "comment" => "Allègement du flacon recommandé" - ]; + "mention" => "Non défini", + "comment" => "Pas d'évaluation disponible", + ]; +} + +function processDTLProposals($page) { + $proposals = []; + + foreach ($page->dtlProposals()->toStructure() as $proposal) { + $location = $proposal->DTLProposalLocation()->value(); + $DTLProposal = null; + + switch ($location) { + case 'proposal': + $proposalPage = $page->find('proposal'); + $proposalFile = $proposal->DTLproposal()->toFile(); + + if ($proposalPage && $proposalFile) { + $index = $proposalPage->pdf()->toFiles()->indexOf($proposalFile); + $DTLProposal = [ + "location" => "proposal", + "path" => "/projects/" . $page->slug() . "?dialog=proposal&fileIndex=" . $index, + "date" => $proposalFile->modified("d/MM/Y"), + "stepLabel" => "Proposition commerciale", + ]; + } + break; + + case 'industrialIdeation': + $proposalPage = $page->find('industrial-ideation'); + $proposalFile = $proposal->DTLindustrialIdeation()->toFile(); + + if ($proposalPage && $proposalFile) { + $DTLProposal = [ + "location" => "industrialIdeation", + "path" => "/projects/" . $page->slug() . "?dialog=industrial-ideation", + "date" => $proposalFile->modified("d/MM/Y"), + "stepLabel" => "Idéation industrielle", + ]; + } + break; + + case 'virtualSampleDynamicTrack': + $proposalPage = $proposal->DTLVirtualSampleDynamicTrack()->toPage(); + if ($proposalPage) { + $DTLProposal = [ + "location" => "virtualSampleDynamicTrack", + "path" => "/projects/" . $page->slug() . "?dialog=virtual-sample", + "date" => $proposalPage->modified("d/MM/Y"), + "stepLabel" => "Échantillon virtuel - piste dynamique", + ]; + } + break; + + case 'virtualSampleStaticTrack': + $proposalPage = $page->find('virtual-sample'); + $proposalFile = $proposal->DTLVirtualSampleStaticTrack()->toFile(); + if ($proposalPage && $proposalFile) { + $DTLProposal = [ + "location" => "virtualSampleStaticTrack", + "path" => "/projects/" . $page->slug() . "?dialog=virtual-sample", + "date" => $proposalFile->modified("d/MM/Y"), + "stepLabel" => "Échantillon virtuel - piste statique", + ]; + } + break; + } + + if ($DTLProposal) { + $numberedGlobalGrade = (int) $proposal->DTLGrade()->value() ?? 0; + + $DTLProposal["grades"] = [ + "global" => getGlobalEvaluation($numberedGlobalGrade), + "position" => [ + "complexity" => (int) $proposal->DTLComplexityGrade()->value() ?? 0, + "weight" => (int) $proposal->DTLWeightGrade()->value() ?? 0, + ], + "indicators" => [ + [ + "label" => "design", + "value" => (int) $proposal->DTLDesignGrade()->value() ?? 0, + ], + [ + "label" => "ring", + "value" => (int) $proposal->DTLRingGrade()->value() ?? 0, + ], + [ + "label" => "shoulder", + "value" => (int) $proposal->DTLShoulderGrade()->value() ?? 0, + ], + [ + "label" => "skeleton", + "value" => (int) $proposal->DTLSkeletonGrade()->value() ?? 0, + ], + [ + "label" => "foot", + "value" => (int) $proposal->DTLFootGrade()->value() ?? 0, + ], + [ + "label" => "bottom", + "value" => (int) $proposal->DTLBottomGrade()->value() ?? 0, + ], + ], + ]; + + $proposals[] = $DTLProposal; + } + } + + return $proposals; } $project = [ - "title" => $page->title()->value(), - "url" => $page->url(), - "modified" => $page->modified("Y-MM-d"), - "status" => $page->status(), - "logo" => $page->client()->isNotEmpty() && $page->client()->toPage() ? $page->client()->toPage()->logo()->toFile()->url() : null, - "steps" => $page->getSteps(), - "designToLight" => null + "title" => $page->title()->value(), + "url" => $page->url(), + "modified" => $page->modified("Y-MM-d"), + "status" => $page->status(), + "logo" => $page->client()->isNotEmpty() && $page->client()->toPage() + ? $page->client()->toPage()->logo()->toFile()->url() + : null, + "steps" => $page->getSteps(), + "designToLight" => $page->isDTLEnabled() ? processDTLProposals($page) : null, ]; - if ($page->isDTLEnabled()) { - $DTLProposal = null; - $proposalLocation = $page->DTLProposalLocation()->value(); - - switch ($proposalLocation) { - case 'proposal': - $proposalPage = $page->find('proposal'); - $proposalFile = $page->DTLProposal()->toFile(); - - if ($proposalPage && $proposalFile) { - $index = $proposalPage->pdf()->toFiles()->indexOf($proposalFile); - $DTLProposal = [ - "location" => "proposal", - "path" => "/projects/" . $page->slug() . "?dialog=proposal&fileIndex=" . $index, - "date" => $proposalFile->modified("Y-MM-d"), - "stepLabel" => "Proposition commerciale", - ]; - } - break; - - case 'industrialIdeation': - $proposalPage = $page->find('industrial-ideation'); - $proposalFile = $page->DTLindustrialIdeation()->toFile(); - - if ($proposalPage && $proposalFile) { - $index = $proposalPage->pdf()->toFiles()->indexOf($proposalFile); - $DTLProposal = [ - "location" => "proposal", - "path" => "/projects/" . $page->slug() . "?dialog=industrial-ideation&fileIndex=" . $index, - "date" => $proposalFile->modified("Y-MM-d"), - "stepLabel" => "Idéation industrielle" - ]; - } - break; - - case 'virtualSampleDynamicTrack': - $proposalPage = $page->DTLVirtualSampleDynamicTrack()->toPage(); - - if ($proposalPage) { - $DTLProposal = [ - "location" => "proposal", - "path" => "/projects/" . $page->slug() . "?dialog=virtual-sample", - "date" => $proposalPage->modified("Y-MM-d"), - "stepLabel" => "Échantillon virtuel" - ]; - } - break; - - case 'virtualSampleStaticTrack': - $proposalPage = $page->find('virtual-sample'); - $proposalFile = $page->DTLVirtualSampleStaticTrack()->toFile(); - - if ($proposalPage && $proposalFile) { - $DTLProposal = [ - "location" => "proposal", - "path" => "/projects/" . $page->slug() . "?dialog=virtual-sample", - "date" => $proposalFile->modified("Y-MM-d"), - "stepLabel" => "Échantillon virtuel" - ]; - } - break; - } - - if ($page->DTLGrade()->isNotEmpty()) { - $numberedGlobalGrade = (int) $page->DTLGrade()->value() ?? 0; - $DTLProposal["grades"] = [ - "global" => getGlobalEvaluation($numberedGlobalGrade), - "indicators" => [ - [ - "label" => "design", - "value" => (int) $page->DTLDesignGrade()->value() ?? 0, - ], - [ - "label" => "ring", - "value" => (int) $page->DTLRingGrade()->value() ?? 0, - ], - [ - "label" => "shoulder", - "value" => (int) $page->DTLShoulderGrade()->value() ?? 0, - ], - [ - "label" => "skeleton", - "value" => (int) $page->DTLSkeletonGrade()->value() ?? 0, - ], - [ - "label" => "foot", - "value" => (int) $page->DTLFootGrade()->value() ?? 0, - ], - [ - "label" => "bottom", - "value" => (int) $page->DTLBottomGrade()->value() ?? 0, - ] - ], - ]; - } - - $project["designToLight"] = $DTLProposal; - } - - $pageData = array_merge($genericData, $project); echo json_encode([ - "page" => $pageData, - "user" => $userData -]); \ No newline at end of file + "page" => $pageData, + "user" => $userData, +]); diff --git a/src/App.vue b/src/App.vue index a718655..e9cb19a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -4,8 +4,11 @@ - - + + + + diff --git a/src/components/design-to-light/DTLPanel.vue b/src/components/design-to-light/DTLPanel.vue index 25e7be5..b1f32a1 100644 --- a/src/components/design-to-light/DTLPanel.vue +++ b/src/components/design-to-light/DTLPanel.vue @@ -1,23 +1,29 @@