From 45df7d5eb4e30e4218142e713ceb51c5ce22832a Mon Sep 17 00:00:00 2001 From: Kerem Kayacan Date: Wed, 23 Jun 2021 13:20:47 +0300 Subject: [PATCH] New snippet: View settings dialog calendar --- ...iew-settings-dialog-on-calendar-select.txt | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/new/view-settings-dialog-on-calendar-select.txt diff --git a/src/new/view-settings-dialog-on-calendar-select.txt b/src/new/view-settings-dialog-on-calendar-select.txt new file mode 100644 index 0000000..19ade19 --- /dev/null +++ b/src/new/view-settings-dialog-on-calendar-select.txt @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + onFilterButtonPressed: function (oEvent) { + this.createViewSettingsDialog("co.arteis.thm-ftconfirm.view.FilterDialog"); + }, + + createViewSettingsDialog: function (sDialogFragmentName) { + var oDialog = this._mViewSettingsDialogs[sDialogFragmentName]; + var oView = this.getView(); + + if (!oDialog) { + Fragment.load({ + id: oView.getId(), + name: sDialogFragmentName, + controller: this + }).then(function (oCreatedDialog) { + // connect dialog to the root view of this component (models, lifecycle) + oView.addDependent(oCreatedDialog); + this._mViewSettingsDialogs[sDialogFragmentName] = oCreatedDialog; + if (Device.system.desktop) { + oCreatedDialog.addStyleClass("sapUiSizeCompact"); + } + + // var aFilterItems = oCreatedDialog.getFilterItems(); + // for (var i = 0; i < aFilterItems.length; i++) { + // if (aFilterItems[i].getProperty("key") === "ICreatedate" || aFilterItems[i].getProperty("key") === "IDate") { + // aFilterItems[i].setFilterCount(1); + // aFilterItems[i].setSelected(true); + // } + // } + + // this.byId("promotionDateCalendar").addSelectedDate(new DateRange({ + // startDate: this.selectedDates["ICreatedate"] + // })); + // this.byId("priceKeyDateCalendar").addSelectedDate(new DateRange({ + // startDate: this.selectedDates["IDate"] + // })); + + oCreatedDialog + .setFilterSearchCallback(null) + .setFilterSearchOperator(sap.m.StringFilterOperator.Contains).open(); + }.bind(this)); + } else { + oDialog.open(); + } + }, + + onCalendarSelect: function (oEvent) { + this.selectedDates[oEvent.getSource().data("key")] = oEvent.getSource().getSelectedDates()[0].getProperty("startDate"); + var aFilterItems = oEvent.getSource().getParent().getParent().getParent().getParent().getFilterItems(); + this.dStartDate = oEvent.getSource().getSelectedDates()[0].getProperty("startDate"); + this.dEndDate = oEvent.getSource().getSelectedDates()[0].getProperty("endDate"); + if (!this.dEndDate) { + this.dEndDate = new Date(this.dStartDate.getTime()); + } + var iDayCount = ((this.dEndDate.getTime() - this.dStartDate.getTime()) / (1000 * 60 * 60 * 24)) + 1; + for (var i = 0; i < aFilterItems.length; i++) { + if (aFilterItems[i].getProperty("key") === oEvent.getSource().data("key")) { + aFilterItems[i].setFilterCount(iDayCount); + aFilterItems[i].setSelected(true); + break; + } + } + }, \ No newline at end of file