Commit a82a0481 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Review the logic using disabled page.

parent 06d7029d
......@@ -21,12 +21,12 @@ Ext.define('Trp.wizard.Harvester', {
// private properties for internationalisation
textCategory: [
"<h4> 3/5 category</h4>",
"<h4> 3/7 category</h4>",
"<p>Select the <i>category of publication</i> you are looking for:</p>"
],
textCollaboration1: [
"<h4> 4/5 collaboration</h4>",
"<h4> 5/7 collaboration</h4>",
"<p>Enter the name of the collaboration:</p>"
],
......@@ -39,7 +39,7 @@ Ext.define('Trp.wizard.Harvester', {
],
textPeople1: [
"<h4> 4/5 people</h4>",
"<h4> 7/7 people</h4>",
"<p>Enter names of the people.<br>",
"One name per line.<br>",
"Possible value can be: <i>John Doe</i> or <i>j doe</i> or <i>doe</i>.",
......@@ -52,7 +52,7 @@ Ext.define('Trp.wizard.Harvester', {
],
textProducer: [
"<h4> 3/5 producer</h4>",
"<h4> 4/7 producer</h4>",
"Publications are produced by:"
],
......@@ -61,7 +61,7 @@ Ext.define('Trp.wizard.Harvester', {
textProducerPeople: 'People not belonging to a collaboration',
textProject1: [
"<h4> 5/5 project</h4>",
"<h4> 6/7 project</h4>",
"<p>Associate the found publications to my project:</p>"
],
......@@ -89,9 +89,6 @@ Ext.define('Trp.wizard.Harvester', {
"when all fields are defined.</p>"
],
// private shorcuts
fieldStore: null,
// jshint strict: false
// private method requires by the Ext JS component model
......@@ -112,72 +109,21 @@ Ext.define('Trp.wizard.Harvester', {
me.pageProject()
]);
// shortcuts
me.fieldStore = me.down('#fieldStore');
// handlers
me.down('#fieldProducer').on('change', me.onProducerChange, me);
me.down('#fieldStore').on('change', me.onStoreChange, me);
// set the default store and trigger the handler onStoreChange
me.down('#fieldStore').setValue('inspirehep.net');
// set the default producer triggering the handler onProducerChange
// set the default producer value and trigger the handler onProducerChange
me.down('#fieldProducer').setValue({
producer: "collaboration"
});
// handlers
me.down('#pageCategory').on('beforeactivate', me.onCategory, me);
},
// jshint strict: true
/**
* Handler call when the page category is activated
* The page category contains a ComboBox which values depend
* on the selected store. The ComboBox store is loaded with the
* correct values.
*
* @param {Ext.panel.Panel}
* the page category
*
*/
onCategory: function (newCard) {
"use strict";
var me = this,
combo = newCard.down('#fieldCategory'),
comboStore = combo.getStore(),
selectedStore = me.fieldStore.getValue();
combo.clearValue();
if (selectedStore === "cds.cern.ch") {
comboStore.loadData([{
"category": "articles"
}, {
"category": "notes"
}, {
"category": "preprints"
}, {
"category": "proceedings"
}, {
"category": "reports"
}, {
"category": "talks"
}, {
"category": "theses"
}]);
} else if (selectedStore === "inspirehep.net") {
comboStore.loadData([{
"category": "articles"
}, {
"category": "proceedings"
}]);
} else {
comboStore.loadData([]);
}
},
/**
* Handler call when the collaboration / People is selected
* The method hide the unwanted page and setup
......@@ -218,6 +164,62 @@ Ext.define('Trp.wizard.Harvester', {
}
},
onStoreChange: function (combo) {
"use strict";
var me = this,
fieldCategory = me.down("#fieldCategory"),
storeCategory = fieldCategory.getStore(),
selectedStore = combo.getValue();
// choice of category depends on the selected store
fieldCategory.clearValue();
if (selectedStore === "cds.cern.ch") {
storeCategory.loadData([{
"category": "article"
}, {
"category": "note"
}, {
"category": "preprint"
}, {
"category": "proceeding"
}, {
"category": "report"
}, {
"category": "talk"
}, {
"category": "thesis"
}]);
} else if (selectedStore === "inspirehep.net") {
storeCategory.loadData([{
"category": "article"
}, {
"category": "proceeding"
}]);
} else {
storeCategory.loadData([]);
}
// wizard pages depends on the selected store
if (selectedStore === "cds.cern.ch") {
me.down('#pageProducer').setDisabled(true);
me.down('#pageCollaborationOrPeople').setDisabled(true);
} else if (selectedStore === "inspirehep.net") {
me.down('#pageProducer').setDisabled(false);
me.down('#pageCollaborationOrPeople').setDisabled(false);
}
// Setup of the allowBlank configuration
},
pageCategory: function () {
"use strict";
......@@ -242,9 +244,10 @@ Ext.define('Trp.wizard.Harvester', {
itemId: 'fieldCategory',
queryMode: 'local',
name: 'category',
selectFirst: true,
store: categories,
valueField: 'category',
xtype: 'combobox'
xtype: 'xcombobox'
}]
};
......@@ -353,10 +356,6 @@ Ext.define('Trp.wizard.Harvester', {
inputValue: 'people',
name: 'producer'
}],
listeners: {
change: me.onProducerChange,
scope: me
},
vertical: true,
xtype: 'radiogroup'
}]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment