diff --git a/src/App.vue b/src/App.vue index 7e3156957389ae3f4f30c8a4aad02f83a9cfb6f0..ec22a7b57c5c28f394fe2f3903caea7d1a240d95 100644 --- a/src/App.vue +++ b/src/App.vue @@ -106,6 +106,7 @@ import Scenario from '@/domain/Scenario' bindings: scenarioExport.cycles[i].idealAssembly } const cycle : Cycle = { + isEvaluation: scenarioExport.cycles[i].isEvaluation, idealAssembly: ideal } scenario.cycles.push(cycle) @@ -114,6 +115,7 @@ import Scenario from '@/domain/Scenario' }, addEmptyCycle: function (): void { const cycle: Cycle = { + isEvaluation: false, idealAssembly: { environment: { components: new Array<Component>() }, bindings: new Array<Binding>() @@ -125,6 +127,7 @@ import Scenario from '@/domain/Scenario' if (this.scenario.cycles.length > 0) { const idealAssemblyToCopy : Assembly = this.scenario.cycles[this.scenario.cycles.length - 1].idealAssembly const cycle: Cycle = { + isEvaluation: this.scenario.cycles[this.scenario.cycles.length - 1].isEvaluation, idealAssembly: { environment: { components: JSON.parse(JSON.stringify(idealAssemblyToCopy.environment.components)) @@ -154,6 +157,7 @@ import Scenario from '@/domain/Scenario' copyEnvLastCycle: function (): void { if (this.scenario.cycles.length > 0) { const cycle = { + isEvaluation: this.scenario.cycles[this.scenario.cycles.length - 1].isEvaluation, idealAssembly: { environment: { // deep copy @@ -181,6 +185,7 @@ import Scenario from '@/domain/Scenario' const cycle: Cycle = this.scenario.cycles[i] const cycleData: CycleExport = { step: i, + isEvaluation: cycle.isEvaluation, environment: cycle.idealAssembly.environment.components, idealAssembly: cycle.idealAssembly.bindings } diff --git a/src/components/CycleViewer.vue b/src/components/CycleViewer.vue index 47c591779f88e1ac111ffb39e03a7595eede02f1..29a6f1177a37344b7203ffa90dd4199bdf727568 100644 --- a/src/components/CycleViewer.vue +++ b/src/components/CycleViewer.vue @@ -1,7 +1,13 @@ <template> <div class="card m-auto w-50" @drop="componentOnDrop($event)" @dragenter.prevent @dragover.prevent> <div class="card-body"> - <p>Cycle number {{step}} <button data-cy="deleteCycle" class="btn btn-danger ml-2" @click="removeItself"><i class="far fa-times-circle"/></button></p> + <p>Cycle number {{step}} + <button data-cy="deleteCycle" class="btn btn-danger ml-2" @click="removeItself"> + <i class="far fa-times-circle"/> + </button> + </p> + <p v-if="step > 0" class="evaluation"><input type="checkbox" v-model="this.cycle.isEvaluation"/> Evaluation</p> + <hr/> <ul data-cy="cycleComponentsList" class="list-group"> <li class="list-group-item" v-for="component in cycle.idealAssembly.environment.components" :key="component"> <h5>{{component.name}} <button class="btn btn-primary btn-sm" @click="removeCycleComponent(component)"><i class="far fa-times-circle"/></button></h5> @@ -114,3 +120,9 @@ export default class CycleViewer extends Vue { cycle!: Cycle } </script> +<style> +.evaluation { + color: grey; + font-style: italic; +} +</style> diff --git a/src/domain/Cycle.ts b/src/domain/Cycle.ts index de6204b60564cc4667ae17105e213c0b45d2385a..4552120bcc1a64786423f3e528e2ac4405687a1c 100644 --- a/src/domain/Cycle.ts +++ b/src/domain/Cycle.ts @@ -1,6 +1,7 @@ import Assembly from '@/domain/Assembly' interface Cycle { + isEvaluation: boolean; idealAssembly: Assembly; } export default Cycle diff --git a/src/domain/export/CycleExport.ts b/src/domain/export/CycleExport.ts index 2f38f15f64832ee68b63b6c3e651a6613e5bd599..65f85cd21aa5ffd79df803178e007f31ecbfe988 100644 --- a/src/domain/export/CycleExport.ts +++ b/src/domain/export/CycleExport.ts @@ -3,6 +3,7 @@ import Binding from '@/domain/Binding' interface CycleExport { step: number, + isEvaluation: boolean, environment: Array<Component>, idealAssembly: Array<Binding> } diff --git a/src/resources/scenario-oce.schema.json b/src/resources/scenario-oce.schema.json index 2b079b96e7e760637a2dbc6b4a4bd8d0815654af..a05477bf9950729c5bd17e87b4e8b705e127b457 100644 --- a/src/resources/scenario-oce.schema.json +++ b/src/resources/scenario-oce.schema.json @@ -16,6 +16,7 @@ "cycles": [ { "step": 1, + "isEvaluation": false, "environment": [ { "name": "Slider", @@ -97,6 +98,7 @@ }, { "step": 2, + "isEvaluation": false, "environment": [ { "name": "Slider", @@ -237,6 +239,7 @@ [ { "step": 1, + "isEvaluation": false, "environment": [ { "name": "Slider", @@ -318,6 +321,7 @@ }, { "step": 2, + "isEvaluation": true, "environment": [ { "name": "Slider", @@ -412,6 +416,7 @@ "examples": [ { "step": 1, + "isEvaluation": false, "environment": [ { "name": "Slider", @@ -494,6 +499,7 @@ ], "required": [ "step", + "isEvaluation", "environment", "idealAssembly" ], @@ -508,6 +514,16 @@ 1 ] }, + "isEvaluation": { + "$id": "#/properties/cycles/items/anyOf/0/properties/isEvaluation", + "type": "boolean", + "title": "The isEvaluation schema", + "description": "Boolean si le cycle est de type evaluation ou non", + "default": false, + "examples": [ + false + ] + }, "environment": { "$id": "#/properties/cycles/items/anyOf/0/properties/environment", "type": "array", diff --git a/tests/e2e/specs/cycle_management_test.js b/tests/e2e/specs/cycle_management_test.js index 65ff854ddf7d4d97add7e96eaa8f2493878399a8..26e09bf99f42c729269d4f3f50a4e0c5a58dc8be 100644 --- a/tests/e2e/specs/cycle_management_test.js +++ b/tests/e2e/specs/cycle_management_test.js @@ -12,6 +12,14 @@ describe('tests cycle display, creation and deletion', () => { cy.get('[data-cy=cyclesList]').contains('p', 'Cycle number 1') cy.get('[data-cy=cyclesList]').contains('p', 'Cycle number 2') }) + it('creates 2 cycles and check if isEvaluation checkbox is displayed', () => { + cy.get('[data-cy=addEmptyCycle]').click() + cy.get('[data-cy=addEmptyCycle]').click() + cy.get('[data-cy=cyclesList]').contains('p', 'Cycle number 0').parent().as('Cycle0') + cy.get('[data-cy=cyclesList]').contains('p', 'Cycle number 1').parent().as('Cycle1') + cy.get('@Cycle0').contains('p', 'Evaluation').should('not.exist') + cy.get('@Cycle1').contains('p', 'Evaluation') + }) it('uses the copy button for the first cycle', () => { cy.get('[data-cy=cyclesList]').find('li').should('have.length', 0) cy.get('[data-cy=copyNewCycle]').click() @@ -46,6 +54,7 @@ describe('tests cycle display, creation and deletion', () => { // finally, we add a new cycle cy.get('[data-cy=copyNewCycle]').click() cy.get('[data-cy=cyclesList]').contains('p', 'Cycle number 1').parent().as('Cycle1') + cy.get('@Cycle1').contains('p', 'Evaluation') cy.get('@Cycle1').contains('h5', 'CarGPS_1 ') cy.get('@Cycle1').contains('p', 'LocationConsumer') cy.get('@Cycle1').contains('p', 'required') @@ -75,6 +84,7 @@ describe('tests cycle display, creation and deletion', () => { // copy cy.get('[data-cy=deepCopyNewCycle]').click() cy.get('[data-cy=cyclesList]').contains('p', 'Cycle number 1').parent().as('Cycle1') + cy.get('@Cycle1').contains('p', 'Evaluation') cy.get('@Cycle1').find('h5').should('have.length', 3) cy.get('@Cycle1').contains('h5', 'ManualGPS_1').parent().find('select').find(':selected').should('have.text', 'OutletLocalizer_1: Location') }) diff --git a/tests/resources/scenarios/lamps_scenario_extinction.json b/tests/resources/scenarios/lamps_scenario_extinction.json index 1d18532c3e1fbedf5354314d83a968d966391a2b..47ef0daf813d0a3b557d89e2017cf99f9889bebc 100644 --- a/tests/resources/scenarios/lamps_scenario_extinction.json +++ b/tests/resources/scenarios/lamps_scenario_extinction.json @@ -7,6 +7,7 @@ "cycles": [ { "step": 0, + "isEvaluation": false, "environment": [ { "name": "Lamp 1_1", @@ -59,6 +60,7 @@ }, { "step": 1, + "isEvaluation": false, "environment": [ { "name": "Lamp 1_1", @@ -111,6 +113,7 @@ }, { "step": 2, + "isEvaluation": true, "environment": [ { "name": "Lamp 1_1", diff --git a/tests/resources/scenarios/single_step_scenario.json b/tests/resources/scenarios/single_step_scenario.json index 34fec6fd17e695f9444f174217e581a66c759a83..4998edb5849f12cd31943c1f74fdaabb0880e1da 100644 --- a/tests/resources/scenarios/single_step_scenario.json +++ b/tests/resources/scenarios/single_step_scenario.json @@ -7,6 +7,7 @@ "cycles": [ { "step": 0, + "isEvaluation": false, "environment": [ { "name": "PhoneGPS_1",