Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference-list-Initializer #1444

Open
gideruette opened this issue Sep 12, 2017 · 0 comments
Open

Reference-list-Initializer #1444

gideruette opened this issue Sep 12, 2017 · 0 comments
Assignees

Comments

@gideruette
Copy link
Contributor

gideruette commented Sep 12, 2017

Current behaviour

We have to create initializer and services for all referenceList

Expected behaviour

reference-list-initializer
import { config } from 'focus-core/reference';
// Path to the reference service.
const referenceService = require('../../services/commun/reference');

// chargez ici toutes vos listes de référence
export const referenceNameList = [
    'etatDeclaration',
    'etatLrb',
    'profil',
    'role',
    'typeTaxe',
    'typePeriode',
    'trimestre',
    'etatPaiement',
    'classeAeroport',
    'moyenPaiement'
];
//See AutoForm
export const referenceNameMap = {
    edeCd: 'etatDeclaration',
    elrCd: 'etatLrb',
    proId: 'profil',
    rolCd: 'role',
    ttaCd: 'typeTaxe',
    tpeCd: 'typePeriode',
    triCd: 'trimestre',
    epaCd: 'etatPaiement',
    claCd: 'classeAeroport',
    mpaCd: 'moyenPaiement'
};


const specificReferences = {};

const getServiceConfig = function() {
    const referenceConfig = specificReferences;
    for (const key in referenceNameList) {
        if(referenceNameList.hasOwnProperty(key)) {
            const referenceName = referenceNameList[key];
            referenceConfig[referenceName] = referenceService.getDefaultReferenceService(referenceName);
        }
    }
    return referenceConfig;
};

export default () => {
    config.set(getServiceConfig());
};

services/commun//reference.js
export default {
    getDefaultReferenceService(referenceName) {
        return () => {
            return server.get(referenceServiceRoot + '/' + referenceName, null);
        };
    },
    getAutoCompleteServices(referenceName) {
        return {
            querySearcher: (texte) => {
                return server.get(referenceServiceRoot + '/querySearcher/' + referenceName + '?texte=${texte}',
                    { texte },
                    { parser: totalCountWrapperJsonParser });
            },
            keyResolver: (id) =>{
                return server.get(referenceServiceRoot + '/keyResolver/' + referenceName + '?id=${id}', { id });
            }
        };
    }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants