dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32539
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16605: PT future periods.
------------------------------------------------------------
revno: 16605
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-09-01 18:24:55 +0200
message:
PT future periods.
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js 2014-09-01 13:32:07 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js 2014-09-01 16:24:55 +0000
@@ -2547,6 +2547,8 @@
relativePeriod,
fixedPeriodAvailable,
fixedPeriodSelected,
+ onPeriodTypeSelect,
+ periodType,
period,
treePanel,
userOrganisationUnit,
@@ -4197,6 +4199,40 @@
}
});
+ onPeriodTypeSelect = function() {
+ var type = periodType.getValue(),
+ periodOffset = periodType.periodOffset,
+ generator = ns.core.init.periodGenerator,
+ periods = generator.generateReversedPeriods(type, type === 'Yearly' ? periodOffset - 5 : periodOffset);
+
+ for (var i = 0; i < periods.length; i++) {
+ periods[i].id = periods[i].iso;
+ }
+
+ fixedPeriodAvailableStore.setIndex(periods);
+ fixedPeriodAvailableStore.loadData(periods);
+ ns.core.web.multiSelect.filterAvailable(fixedPeriodAvailable, fixedPeriodSelected);
+ };
+
+ periodType = Ext.create('Ext.form.field.ComboBox', {
+ cls: 'ns-combo',
+ style: 'margin-bottom:1px',
+ width: ns.core.conf.layout.west_fieldset_width - ns.core.conf.layout.west_width_padding - 62 - 62 - 2,
+ valueField: 'id',
+ displayField: 'name',
+ emptyText: NS.i18n.select_period_type,
+ editable: false,
+ queryMode: 'remote',
+ store: periodTypeStore,
+ periodOffset: 0,
+ listeners: {
+ select: function() {
+ periodType.periodOffset = 0;
+ onPeriodTypeSelect();
+ }
+ }
+ });
+
period = {
xtype: 'panel',
title: '<div class="ns-panel-title-period">Periods</div>',
@@ -4258,44 +4294,16 @@
bodyStyle: 'border-style:none',
style: 'margin-top:0px',
items: [
- {
- xtype: 'combobox',
- cls: 'ns-combo',
- style: 'margin-bottom:1px',
- width: ns.core.conf.layout.west_fieldset_width - ns.core.conf.layout.west_width_padding - 62 - 62 - 2,
- valueField: 'id',
- displayField: 'name',
- emptyText: NS.i18n.select_period_type,
- editable: false,
- queryMode: 'remote',
- store: periodTypeStore,
- periodOffset: 0,
- listeners: {
- select: function() {
- var periodType = this.getValue(),
- generator = ns.core.init.periodGenerator,
- periods = generator.filterFuturePeriodsExceptCurrent(generator.generateReversedPeriods(periodType, this.periodOffset));
-
- for (var i = 0; i < periods.length; i++) {
- periods[i].id = periods[i].iso;
- }
-
- fixedPeriodAvailableStore.setIndex(periods);
- fixedPeriodAvailableStore.loadData(periods);
- ns.core.web.multiSelect.filterAvailable(fixedPeriodAvailable, fixedPeriodSelected);
- }
- }
- },
+ periodType,
{
xtype: 'button',
text: NS.i18n.prev_year,
style: 'margin-left:1px; border-radius:2px',
height: 24,
handler: function() {
- var cb = this.up('panel').down('combobox');
- if (cb.getValue()) {
- cb.periodOffset--;
- cb.fireEvent('select');
+ if (periodType.getValue()) {
+ periodType.periodOffset--;
+ onPeriodTypeSelect();
}
}
},
@@ -4305,10 +4313,9 @@
style: 'margin-left:1px; border-radius:2px',
height: 24,
handler: function() {
- var cb = this.up('panel').down('combobox');
- if (cb.getValue() && cb.periodOffset < 0) {
- cb.periodOffset++;
- cb.fireEvent('select');
+ if (periodType.getValue()) {
+ periodType.periodOffset++;
+ onPeriodTypeSelect();
}
}
}