Skip to content

Commit

Permalink
dispatch keywords at the right places
Browse files Browse the repository at this point in the history
  • Loading branch information
PookMook committed Jul 11, 2017
1 parent 5f998e1 commit 6eb92cb
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 25 deletions.
4 changes: 2 additions & 2 deletions yamlEditor/dist/js/bundle.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion yamlEditor/src/js/components/Keywords.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import React from 'react'
import _ from 'lodash'

export function Keywords(){
let selected = _.get(store.getState().misc,"selectedCategories",[]);
let uncontrolledKeywords = _.get(store.getState().misc,"uncontrolledKeywords",[]);
let categories = _.get(store.getState().misc,"categories",[]);
let selected = categories.filter(function(category){
return category.selected === true;
});
return(
<section className="group">
<h1><i className="fa fa-tag" aria-hidden="true"></i> Mots clés</h1>
Expand Down
2 changes: 1 addition & 1 deletion yamlEditor/src/js/components/Rubriques.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function Rubriques(){
return(
<section className="group">
<h1><i className="fa fa-check-square-o" aria-hidden="true"></i> Catégories</h1>
{rubriques.map((o,i)=>(<Rubrique key={i} index={i} label={o.fr}/>))}
{rubriques.map((o,i)=>(<Rubrique key={i} index={i} label={o.label}/>))}
</section>
)
}
Expand Down
14 changes: 8 additions & 6 deletions yamlEditor/src/js/redux/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,20 @@ function compileKeywords(state){
let rubriques = state.misc.rubriques.filter(function(rubrique){
return rubrique.selected === true;
});
state.obj.typeArticle = rubriques.map((r)=>(r.label)).join(', ');

//compute typeArticle
let categories = state.misc.categories.filter(function(category){
return category.selected === true;
});
state.misc.selectedCategories = categories;
state.obj.controlledKeywords = categories;

//Generate new keywords in state.obj
let keywords = [...rubriques, ...categories,...state.misc.uncontrolledKeywords];
//Compute uncontrolledKeywords
state.obj.keyword_fr = [];
state.obj.keyword_en = [];
for(let i=0;i<keywords.length;i++){
state.obj.keyword_fr.push(keywords[i].fr);
state.obj.keyword_en.push(keywords[i].en);
for(let i=0;i<state.misc.uncontrolledKeywords.length;i++){
state.obj.keyword_fr.push(state.misc.uncontrolledKeywords[i].fr);
state.obj.keyword_en.push(state.misc.uncontrolledKeywords[i].en);
}
console.log("update keywords");
return state;
Expand Down
30 changes: 15 additions & 15 deletions yamlEditor/src/js/redux/rubriques.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
export let rubriques = [
{"it":"TODO Revue en ligne","en":"TODO Revue en ligne","fr":"Revue en ligne","selected":false},
{"it":"TODO Essai","en":"TODO Essai","fr":"Essai","selected":false},
{"it":"TODO Création","en":"TODO Création","fr":"Création","selected":false},
{"it":"TODO L'édition papier de Sens-Public","en":"TODO L'édition papier de Sens-Public","fr":"L'édition papier de Sens-Public","selected":false},
{"it":"TODO Archive","en":"TODO Archive","fr":"Archive","selected":false},
{"it":"TODO Info revue","en":"TODO Info revue","fr":"Info revue","selected":false},
{"it":"TODO Lecture","en":"TODO Lecture","fr":"Lecture","selected":false},
{"it":"TODO Actes de colloque","en":"TODO Actes de colloque","fr":"Actes de colloque","selected":false},
{"it":"TODO Sommaire dossier","en":"TODO Sommaire dossier","fr":"Sommaire dossier","selected":false},
{"it":"TODO Entretien","en":"TODO Entretien","fr":"Entretien","selected":false},
{"it":"TODO Chronique","en":"TODO Chronique","fr":"Chronique","selected":false},
{"it":"TODO Qui sommes nous ?","en":"TODO Qui sommes nous ?","fr":"Qui sommes nous ?","selected":false},
{"it":"TODO Infos générales","en":"TODO Infos générales","fr":"Infos générales","selected":false},
{"it":"TODO Lu sur le web","en":"TODO Lu sur le web","fr":"Lu sur le web","selected":false},
{"it":"TODO Autres informations","en":"TODO Autres informations","fr":"Autres informations","selected":false}
{"label":"Revue en ligne","selected":false},
{"label":"Essai","selected":false},
{"label":"Création","selected":false},
{"label":"L'édition papier de Sens-Public","selected":false},
{"label":"Archive","selected":false},
{"label":"Info revue","selected":false},
{"label":"Lecture","selected":false},
{"label":"Actes de colloque","selected":false},
{"label":"Sommaire dossier","selected":false},
{"label":"Entretien","selected":false},
{"label":"Chronique","selected":false},
{"label":"Qui sommes nous ?","selected":false},
{"label":"Infos générales","selected":false},
{"label":"Lu sur le web","selected":false},
{"label":"Autres informations","selected":false}
];

0 comments on commit 6eb92cb

Please sign in to comment.