Commit d8d292b1 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

- Champ RNSR dans la fiche organisation (service open data)

parent dd8e7954
Loading
Loading
Loading
Loading
Loading
+8 −1
Changes for front/gulpfile.js: 8 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -92,7 +92,14 @@ function componentTextarea(cb) {
exports.componentTextarea = componentTextarea;
exports.componentTextareaWatch = function(cb){ watch('./src/components/TextareaField.vue', componentTextarea); }

let commands = ['activityDocument', 'administrationPcru', 'administrationPcruPC'];
function componentRNSRField(cb) {
    compileComponent('RNSRField');
    cb();
}
exports.componentRNSRField = componentRNSRField;
exports.componentRNSRFieldWatch = function(cb){ watch('./src/components/RNSRField.vue', componentRNSRField); }

let commands = ['activityDocument', 'administrationPcru', 'administrationPcruPC', 'componentRNSRField'];

function defaultTask(cb) {
    console.log("Usage : ");
+102 −0
Changes for front/src/components/RNSRField.vue: 102 added lines, 0 removed lines.
Original line number Diff line number Diff line
<template>
    <div id="rnsr">
      <transition name="fade">
        <div id="rnsr-modal" v-if="modal" class="overlay">
          <div class="overlay-content">
            <h2>
              Recherche le numéro dans le <strong>Répertoire National des Structures de Recherche</strong>
              <span href="#" class="overlay-closer" @click="modal = false">X</span>
            </h2>
            <input type="search" v-model="search" class="form-control" />
            <hr>
            <section class="list-selector" v-if="results">
              <div v-for="a in results" >
                <article @click="handlerSelectItem(a)" class="">
                  <code title="Numéro National des Structures" class="cartouche grey xs">{{ a.fields.numero_national_de_structure }}</code>
                  <strong>{{ a.fields.libelle }}</strong>
                  <small> <i class="icon-location"></i> {{ a.fields.commune }}</small>
                </article>
              </div>
            </section>
            <div class="alert alert-info" v-else>
              Aucun résultat
            </div>

          </div>
        </div>
      </transition>
      <a class="btn btn-default" title="Rechercher dans le répertoire National des Structures de recherche (RNSR)"
         @click="handlerShow">
        <i class="icon-search-outline"></i>
        Rechercher
      </a>
    </div>
</template>
<script>
/******************************************************************************************************************/
/* ! DEVELOPPEUR
Depuis la racine OSCAR :

cd front

Pour compiler en temps réél :
node node_module/.bin/gulp RNSRFieldWatch

Pour compiler :
node node_module/.bin/gulp RNSRField

 */
    export default {
        props: {
            class: { default: 'form-control' },
            code: { default: '' }
        },

        data() {
            return {
              search: "",
              modal: false,
              results: {},
              error: null,
              first: true
            }
        },

        watch: {
            search(val){
                this.find(val);
            }
        },

        methods: {
          find(exp){
            this.$http.get('https://data.enseignementsup-recherche.gouv.fr/api/records/1.0/search/?dataset=fr-esr-structures-recherche-publiques-actives&q=' + this.search).then(
                ok => {
                  this.results = ok.data.records;
                },
                fail => {
                  this.error = fail
                }
            )
          },

          handlerShow(){
            if( this.code && this.first ){
              this.search = this.code;
              this.find(this.code);
              this.first = false;
            }
            this.modal = !this.modal;
          },

          handlerSelectItem(item){
            this.$emit('select', item.fields.numero_national_de_structure);
            this.modal = false;
          }
        },

        mounted() {

        }
    }
</script>
 No newline at end of file
+5 −1
Changes for module/Oscar/src/Oscar/Factory/ActivityPcruInfoFromActivityFactory.php: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -47,14 +47,18 @@ class ActivityPcruInfoFromActivityFactory
        }


        $organizationsParsed = [];
        /** @var ActivityOrganization $unite */
        foreach ($activity->getOrganizationsWithRole($roleStructureToFind) as $unite) {
            $organizationsParsed[] = (string)$unite->getOrganization();
            if( $unite->getOrganization()->getLabintel() ){
                $codeUniteLabintel = $unite->getOrganization()->getLabintel();
                $sigleUnit = $unite->getOrganization()->getShortName();
            }
        }

        if( $codeUniteLabintel == "" ){
            throw new OscarException("Le $roleStructureToFind n'a pas de code LABINTEL");
            throw new OscarException("Le $roleStructureToFind (".implode(', ', $organizationsParsed).") n'a pas de code LABINTEL");
        }

        // Recherche automatique du responsable scientifique
+20 −0
Changes for module/Oscar/view/oscar/organization/form.phtml: 20 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -88,6 +88,26 @@
                <span class="input-group-addon">N°RNSR</span>
                <?= $this->formInput($form->get('rnsr')) ?>
                <?= $this->formElementErrors($form->get('rnsr')); ?>
                <div id="rnsrfield"></div>
                <script>
                    require(['vue', 'vue-resource', 'rnsrfield'], function(Vue, VueResource, RNSRField){
                        /**
                         * Système de recherche des RSNS, pas très classe, mais fonctionnel
                         */
                        var v = new Vue({
                            components: { 'rsnsfield': RNSRField },
                            template: '<rsnsfield @select="selectrsns" :code="\'GREYC\'" />',
                            methods: {
                                selectrsns(foo){
                                    this.$emit('change', foo);
                                }
                            }
                        }).$mount("#rnsrfield");
                        v.$on('change', function(foo){
                            document.querySelector('[name="rnsr"]').value = foo;
                        })
                    })
                </script>
            </div>
        </div>
    </div>
+32 −0
Changes for public/css/_common.scss: 32 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -5519,3 +5519,35 @@ pre.alert-danger, pre.alert-info {
.datepicker-selector .week .week-day:nth-child(odd) {
  background: rgba(0, 0, 0, 0.05);
}

.list-selector {
  display: block;

  div {
    display: block;

    article {
      cursor: pointer;
      display: block;
      align-items: center;
      justify-items: center;
      &:nth-child(even) {
        background: rgba(#0a3783,.05);
      }
      &:hover {
        background: rgba(#9CEFE8,.8);
      }

      strong {
        flex: 5;
      }

      small {
        margin-left: auto;
        flex: 0;
      }
    }
  }


}
 No newline at end of file
Loading