Skip to content

Commit

Permalink
ordre alphabetique
Browse files Browse the repository at this point in the history
  • Loading branch information
PookMook committed Feb 9, 2018
1 parent 75848a3 commit fd10643
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 13 deletions.
7 changes: 3 additions & 4 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ RUN cd /front; npm i
ADD src/package.json /src/package.json
RUN cd /src; npm i

# Working on backend
ADD src /src

# add source
ADD front /front

# build front end
RUN cd /front;npm run dist
RUN cd /front;mv public /src/

# Working on backend
ADD src /src


WORKDIR /src

EXPOSE 80
Expand Down
36 changes: 32 additions & 4 deletions front/assets/Redux/Reducers/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ let sortByTitle = function(a, b) {
if (nameA > nameB) {return 1;}
return 0;
}
let sortByFamily = function(a, b) {
var nameA = a.family.toUpperCase(); // ignore upper and lowercase
var nameB = b.family.toUpperCase(); // ignore upper and lowercase
if (nameA < nameB) {return -1;}
if (nameA > nameB) {return 1;}
return 0;
}
let sortVersions = function(a, b) {
const familyPrio = [3,4,1,2];
var familyA = familyPrio.indexOf(a.id_language);
var familyB = familyPrio.indexOf(b.id_language);
if(familyB == -1){return -1}
if(familyA == -1){return 1}
if (familyA < familyB) {return -1;}
if (familyA > familyB) {return 1;}
return 0;
}


export function login(state = initialState, action) {
Expand All @@ -28,15 +45,21 @@ export function login(state = initialState, action) {
console.log(action.type);
for (var i = 0, len = action.payload.length; i < len; i++) {
lookup[action.payload[i].id_author] = action.payload[i];
action.payload[i].versions.sort(sortVersions);
action.payload[i].title = action.payload[i].versions.map(i=>i.name).join(' / ');
}
action.payload.sort(sortByTitle);
return Object.assign({},state,{authors:action.payload,authorsLookup:lookup})
break;

case 'UPDATE_CITIES':
console.log(action.type);
for (var i = 0, len = action.payload.length; i < len; i++) {
lookup[action.payload[i].id_city] = action.payload[i];
action.payload[i].versions.sort(sortVersions);
action.payload[i].title = action.payload[i].versions.map(i=>i.name).join(' / ');
}
action.payload.sort(sortByTitle);
return Object.assign({},state,{cities:action.payload, citiesLookup:lookup})
break;

Expand All @@ -45,6 +68,7 @@ export function login(state = initialState, action) {
for (var i = 0, len = action.payload.length; i < len; i++) {
lookup[action.payload[i].id_language] = action.payload[i];
}
action.payload.sort(sortByFamily);
return Object.assign({},state,{languages:action.payload,languagesLookup:lookup})
break;

Expand All @@ -71,18 +95,22 @@ export function login(state = initialState, action) {
for (var i = 0, len = action.payload.length; i < len; i++) {
lookup[action.payload[i].id_keyword_category] = action.payload[i];
}
action.payload.sort(sortByTitle);
return Object.assign({},state,{keywordCategory:action.payload,keywordCategoryLookup:lookup})
break;

case 'UPDATE_KEYWORDS':
console.log(action.type);
let unassignedKeywords = [];
for (var i = 0, len = action.payload.length; i < len; i++) {
lookup[action.payload[i].id_keyword] = action.payload[i];
if(!action.payload[i].category){
unassignedKeywords.push(action.payload[i].id_keyword);
}
action.payload[i].versions.sort(sortVersions);
action.payload[i].title = action.payload[i].versions.map(i=>i.title).join(' / ');
lookup[action.payload[i].id_keyword] = action.payload[i];
if(!action.payload[i].category){
unassignedKeywords.push(action.payload[i].id_keyword);
}
}
action.payload.sort(sortByTitle);
return Object.assign({},state,{keywords:action.payload,keywordsLookup:lookup,unassignedKeywords:unassignedKeywords})
break;

Expand Down
2 changes: 1 addition & 1 deletion front/assets/components/App/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ resolveFirst.push(fetch("/api/v1/status",
return null})
.catch(()=>(null)));

resolveFirst.push(fetch('/api/v1/Languages',{
resolveFirst.push(fetch('/api/v2/languages',{
method:'GET',
credentials: 'same-origin'
})
Expand Down
2 changes: 1 addition & 1 deletion front/assets/components/Authors/mainAuthors.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class mainAuthors extends Component {
<h6>anthologia.ecrituresnumeriques.ca/api/v1/authors</h6>

{store.getState().loggedIn && <Link to="/authors/new" className="addto" activeStyle={{ color: 'black' }}>add new author</Link>}
{this.authors.map((author,i)=>(<Link to={"/authors/"+author.id_author} key={"author"+author.id_author} id={author.id_author}>{author.versions.map(a => a.name).join(" / ")}</Link>))}
{this.authors.map((author,i)=>(<Link to={"/authors/"+author.id_author} key={"author"+author.id_author} id={author.id_author}>{author.title}</Link>))}
</main>
);
}
Expand Down
2 changes: 1 addition & 1 deletion front/assets/components/Keywords/mainKeywords.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class mainKeywords extends Component {
<h6>anthologia.ecrituresnumeriques.ca/api/v1/keywords</h6>

{store.getState().loggedIn && <Link to="/keywords/new" className="addto" activeStyle={{ color: 'black' }}>add new keyword</Link>}
{this.keywords.map((keyword,i)=>(<Link to={"/keywords/"+keyword.id_keyword} key={"keyword"+keyword.id_keyword} id={keyword.id_keyword}>{keyword.versions.map(a => a.title).join(" / ")}</Link>))}
{this.keywords.map((keyword,i)=>(<Link to={"/keywords/"+keyword.id_keyword} key={"keyword"+keyword.id_keyword} id={keyword.id_keyword}>{keyword.title}</Link>))}
</main>
);
}
Expand Down
9 changes: 8 additions & 1 deletion front/assets/components/Notes/mainNotes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@ export default class mainNotes extends Component {
}

fetchNotes(){
let sortByTitle = function(a, b) {
var nameA = a.title.toUpperCase(); // ignore upper and lowercase
var nameB = b.title.toUpperCase(); // ignore upper and lowercase
if (nameA < nameB) {return -1;}
if (nameA > nameB) {return 1;}
return 0;
}
let that = this;
fetch('/api/v1/notes')
.then(function(response){
return response.json();
})
.then(function(json){
//console.log(json)
that.notes = json;
that.notes = json.sort(sortByTitle);
that.forceUpdate();
});
}
Expand Down
9 changes: 8 additions & 1 deletion front/assets/components/Scholies/mainScholies.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@ export default class mainScholies extends Component {

fetchScholies(){
let that = this;
let sortByTitle = function(a, b) {
var nameA = a.title.toUpperCase(); // ignore upper and lowercase
var nameB = b.title.toUpperCase(); // ignore upper and lowercase
if (nameA < nameB) {return -1;}
if (nameA > nameB) {return 1;}
return 0;
}
fetch('/api/v1/scholies')
.then(function(response){
return response.json();
})
.then(function(json){
//console.log(json)
that.scholies = json;
that.scholies = json.sort(sortByTitle);
that.forceUpdate();
});
}
Expand Down
1 change: 1 addition & 0 deletions src/config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ module.exports.routes = {

//Languages
'GET /api/v1/languages':'Languages.find',
'GET /api/v2/languages':{model:'languages',blueprint:'find',populate:false},
'POST /api/v1/languages':'Languages.create',
'GET /api/v1/languages/:id':'Languages.findOne',
'POST /api/v1/languages/:id':'Languages.update',
Expand Down

0 comments on commit fd10643

Please sign in to comment.