|  | @@ -12,17 +12,22 @@ import ContentEditable from '@components/editable/ContentEditable.vue';
 | 
											
												
													
														|  |  import CheckboxEditable from '@components/editable/CheckboxEditable.vue';
 |  |  import CheckboxEditable from '@components/editable/CheckboxEditable.vue';
 | 
											
												
													
														|  |  import ImageEditable from '@components/editable/ImageEditable.vue';
 |  |  import ImageEditable from '@components/editable/ImageEditable.vue';
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +import SvgIcon from '@jamescoyle/vue-icon';
 | 
											
												
													
														|  | 
 |  | +import { mdiTextBoxPlusOutline } from '@mdi/js';
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  export default {
 |  |  export default {
 | 
											
												
													
														|  |    props: ['concernement', 'entite', 'eid'],
 |  |    props: ['concernement', 'entite', 'eid'],
 | 
											
												
													
														|  |    emits: ['reloadEntite'],
 |  |    emits: ['reloadEntite'],
 | 
											
												
													
														|  |    data() {
 |  |    data() {
 | 
											
												
													
														|  |      return {
 |  |      return {
 | 
											
												
													
														|  | 
 |  | +      mdiTextBoxPlusOutline_path: mdiTextBoxPlusOutline,
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |    },
 |  |    },
 | 
											
												
													
														|  |    computed: {
 |  |    computed: {
 | 
											
												
													
														|  |      ...mapState(ConcernementsStore,['opened_concernement',
 |  |      ...mapState(ConcernementsStore,['opened_concernement',
 | 
											
												
													
														|  |                                      'ct_concernement',
 |  |                                      'ct_concernement',
 | 
											
												
													
														|  |                                      'ct_entite']),
 |  |                                      'ct_entite']),
 | 
											
												
													
														|  | 
 |  | +    ...mapState(UserStore,['csrf_token']),
 | 
											
												
													
														|  |      field_menace_maintien_label (){
 |  |      field_menace_maintien_label (){
 | 
											
												
													
														|  |        let str;
 |  |        let str;
 | 
											
												
													
														|  |        if (this.concernement.entites_byid[this.eid].menacemaintien < 0) {
 |  |        if (this.concernement.entites_byid[this.eid].menacemaintien < 0) {
 | 
											
										
											
												
													
														|  | @@ -36,6 +41,55 @@ export default {
 | 
											
												
													
														|  |    methods: {
 |  |    methods: {
 | 
											
												
													
														|  |      reloadEntite(){
 |  |      reloadEntite(){
 | 
											
												
													
														|  |        this.$emit('reloadEntite');
 |  |        this.$emit('reloadEntite');
 | 
											
												
													
														|  | 
 |  | +    },
 | 
											
												
													
														|  | 
 |  | +    addSource(){
 | 
											
												
													
														|  | 
 |  | +      console.log('add source');
 | 
											
												
													
														|  | 
 |  | +      const params_parag = {
 | 
											
												
													
														|  | 
 |  | +        type: [{target_id: 'source'}],
 | 
											
												
													
														|  | 
 |  | +        parent_type:{value: 'node'},
 | 
											
												
													
														|  | 
 |  | +        parent_id:{value: this.entite.id},
 | 
											
												
													
														|  | 
 |  | +        parent_field_name:{value: 'field_sources'}
 | 
											
												
													
														|  | 
 |  | +      };
 | 
											
												
													
														|  | 
 |  | +      
 | 
											
												
													
														|  | 
 |  | +      const configs = {
 | 
											
												
													
														|  | 
 |  | +        headers: {'X-CSRF-Token': this.csrf_token}
 | 
											
												
													
														|  | 
 |  | +      };
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +      // call the api
 | 
											
												
													
														|  | 
 |  | +      // https://www.drupal.org/project/paragraphs/issues/3012600
 | 
											
												
													
														|  | 
 |  | +      REST.post(`/entity/paragraph?_format=json`, params_parag, configs)
 | 
											
												
													
														|  | 
 |  | +        .then(({ data }) => {
 | 
											
												
													
														|  | 
 |  | +          console.log('REST post new source parag', data);
 | 
											
												
													
														|  | 
 |  | +          
 | 
											
												
													
														|  | 
 |  | +            const params_node = {
 | 
											
												
													
														|  | 
 |  | +              type: 'entite',
 | 
											
												
													
														|  | 
 |  | +              nid: [{value: this.entite.id}],
 | 
											
												
													
														|  | 
 |  | +              'field_sources': [{
 | 
											
												
													
														|  | 
 |  | +                target_id: data.id[0].value,
 | 
											
												
													
														|  | 
 |  | +                target_revision_id: data.revision_id[0].value
 | 
											
												
													
														|  | 
 |  | +              }]
 | 
											
												
													
														|  | 
 |  | +            };
 | 
											
												
													
														|  | 
 |  | +            
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +            // call the api
 | 
											
												
													
														|  | 
 |  | +            REST.patch(`/node/${this.entite.id}?_format=json`, params_node, configs)
 | 
											
												
													
														|  | 
 |  | +              .then(({ data }) => {
 | 
											
												
													
														|  | 
 |  | +                console.log('REST patch entite new field_sources', data)
 | 
											
												
													
														|  | 
 |  | +                this.reloadEntite();
 | 
											
												
													
														|  | 
 |  | +              })
 | 
											
												
													
														|  | 
 |  | +              .catch(error => {
 | 
											
												
													
														|  | 
 |  | +                console.warn(`Issue with patch node entite field_sources`, error)
 | 
											
												
													
														|  | 
 |  | +                Promise.reject(error)
 | 
											
												
													
														|  | 
 |  | +              })
 | 
											
												
													
														|  | 
 |  | +    
 | 
											
												
													
														|  | 
 |  | +    
 | 
											
												
													
														|  | 
 |  | +        })
 | 
											
												
													
														|  | 
 |  | +        .catch(error => {
 | 
											
												
													
														|  | 
 |  | +          console.warn(`Issue with post new paragraph source`, error)
 | 
											
												
													
														|  | 
 |  | +          Promise.reject(error)
 | 
											
												
													
														|  | 
 |  | +        })
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |    },
 |  |    },
 | 
											
												
													
														|  |    components: {
 |  |    components: {
 | 
											
										
											
												
													
														|  | @@ -43,6 +97,7 @@ export default {
 | 
											
												
													
														|  |      ContentEditable,
 |  |      ContentEditable,
 | 
											
												
													
														|  |      CheckboxEditable,
 |  |      CheckboxEditable,
 | 
											
												
													
														|  |      ImageEditable,
 |  |      ImageEditable,
 | 
											
												
													
														|  | 
 |  | +    SvgIcon
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  </script>
 |  |  </script>
 | 
											
										
											
												
													
														|  | @@ -109,6 +164,14 @@ export default {
 | 
											
												
													
														|  |          :source="source"
 |  |          :source="source"
 | 
											
												
													
														|  |          v-on:reloadEntite="reloadEntite" />
 |  |          v-on:reloadEntite="reloadEntite" />
 | 
											
												
													
														|  |      </section>
 |  |      </section>
 | 
											
												
													
														|  | 
 |  | +    <section 
 | 
											
												
													
														|  | 
 |  | +      v-else-if="entite.can_update"
 | 
											
												
													
														|  | 
 |  | +      class="sources add">
 | 
											
												
													
														|  | 
 |  | +      <div @click="addSource" class="add-source-btn">
 | 
											
												
													
														|  | 
 |  | +        <span>Ajouter une experience vécue</span>
 | 
											
												
													
														|  | 
 |  | +        <svg-icon type="mdi" :path="mdiTextBoxPlusOutline_path"/>
 | 
											
												
													
														|  | 
 |  | +      </div>
 | 
											
												
													
														|  | 
 |  | +    </section>
 | 
											
												
													
														|  |    </section>
 |  |    </section>
 | 
											
												
													
														|  |  </template>
 |  |  </template>
 | 
											
												
													
														|  |  
 |  |  
 |