40 lines
947 B
JavaScript
40 lines
947 B
JavaScript
import ngModule from '../module';
|
|
import SearchPanel from 'core/components/searchbar/search-panel';
|
|
|
|
class Controller extends SearchPanel {
|
|
constructor($, $element) {
|
|
super($, $element);
|
|
|
|
this.getUpcomingCampaing();
|
|
}
|
|
|
|
getUpcomingCampaing() {
|
|
this.$http.get('Campaigns/upcoming').then(res => {
|
|
const filter = this.$.filter;
|
|
filter.campaign = res.data.id;
|
|
});
|
|
}
|
|
|
|
get campaignSelection() {
|
|
return this._campaignSelection;
|
|
}
|
|
|
|
set campaignSelection(value) {
|
|
this._campaignSelection = value;
|
|
|
|
if (!value) return;
|
|
|
|
const filter = this.$.filter;
|
|
const from = new Date(value.dated);
|
|
from.setDate(from.getDate() - value.scopeDays);
|
|
|
|
filter.to = value.dated;
|
|
filter.from = from;
|
|
}
|
|
}
|
|
|
|
ngModule.vnComponent('vnConsumptionSearchPanel', {
|
|
template: require('./index.html'),
|
|
controller: Controller
|
|
});
|