Hello community,

 

I have a detail DocListInFinApp in Application Page and I want to add a fixed filter to the detail based on application current stage. Is there a way to add a fixed filter to the detail to only show specific documents.

 

I have implemented the following code to test the functionality

methods: {
			onEntityInitialized: function() {
 
				this.callParent(arguments);
                this.initFixedFiltersConfig();
			},
			// Initializes the fixed filters.
            initFixedFiltersConfig: function() {
                // Creating a Configuration Object.
                var fixedFilterConfig = {
                    // The schema of the section object is specified as an object schema for fixed filters. 
                    entitySchema: "DocListInFinApp",
                    // Array of filters.
                    filters: [
                        // Owner filter.
                        {
                            // The name of the filter.
                            name: "StageFilter",
                            // Filter header.
                            caption: "StageFilter",
                            // Filter the data from the [Owner] column.
                            columnName: "DocumentListStage",
                            // Current user contact is specified as default value.
                            // Value is received from the system setting.
                            defValue:"69CF135A-9D15-4500-A0D1-E553A7BD5620",
                            // The data type – lookup.
                            dataValueType: this.Terrasoft.DataValueType.LOOKUP,
                            // Filter.
                            filter: BaseFiltersGenerateModule.StageFilter
                        }
                    ]
                };
                // A link to the configurational object is assigned to the [FixedFilterConfig] column.
                this.set("FixedFilterConfig", fixedFilterConfig);
            }
		}

 

Like 0

Like

2 comments

Hello User1997,

 

There is no way to add the fixed filter in the detail using FixedFilterConfig, but you can add additional filtration to the detail records using the following example:

//details object
"Schema386de87bDetailfb4e174c": {
				"schemaName": "Schema386de87bDetail",
				"entitySchemaName": "Document",
				"filter": {
					"detailColumn": "UsrCase",
					"masterColumn": "Id"
				},
				"filterMethod": "CaseStatusFilter"
			}
...
//methods object
CaseStatusFilter: function() {
						var filterGroup = new this.Terrasoft.createFilterGroup();
						filterGroup.logicalOperation = this.Terrasoft.LogicalOperatorType.AND;
						filterGroup.add("ByCaseStatusFilter", this.Terrasoft.createColumnFilterWithParameter(
							this.Terrasoft.ComparisonType.EQUAL, "UsrAvailableCaseStatus", this.get("Status"))
						);
						return filterGroup;
					},

Such a filtration is used for example to list only email activities in the "Email" detail in the contact or account page. The logic is simple: add additional filtration to the already present detail filter. In the case above:

 

1) There was a lookup column added to the Documents object. The lookup column relates to Cases object.

2) There was another lookup column added to the Documents object. The lookup column relates to CaseStatus object.

3) The detail is created on the CasePage to list those documents that are connected to the case (Case column of the Document object is the same as the current case record opened. The detail object is also Document)

 4) Add additional filtration in the "filterMethod": "CaseStatusFilter" part to return only those documents that have the same value in the "UsrAvailableCaseStatus" lookup column (from step 2) as the current case status.

 

Hope this will fit your business logic.

 

Best regards,

Oscar

Oscar Dylan,

Thanks Oscar, 

The problem with this solution is that the filter must be visible to the user. Is there any way we can make the applied filter visible?

Show all comments

Hi Team,



I would like to change the week value in calendar activity.

By default we have Sunday to Monday, i need it to be displayed as Monday to Sunday.



Please find the attachment below,







we see that it is loaded from these modules FixedFilterViewModelV2,FixedFilterViewV2



in FixedFilterViewV2, getPeriodFixedButtonsViewConfig(Filtername) function generates the calendar icon buttons for current day, current week, current month filter and they are binded to "SetCurrentDayPeriod", "SetCurrentWeekPeriod" and month menu button collection correspondingly.

 

function getPeriodFixedButtonsViewConfig(filterName) {
			var localizableStrings = resources.localizableStrings;
			var localizableImages = resources.localizableImages;
			var dayButton = getFixedButtonBaseConfig({
				click: {bindTo: "setCurrentDayPeriod"},
				hint: localizableStrings.TodayCaption,
				imageConfig: localizableImages.DayPeriodButtonImage,
				markerValue: "day",
				classes: {
					wrapperClass: ["day-period-fixed-filter-wrapper-class"],
					imageClass: ["period-fixed-filter-image-class"]
				},
				visible: {bindTo: "dayButtonVisible"}
			});
			var weekButton = getFixedButtonBaseConfig({
				click: {bindTo: "setCurrentWeekPeriod"},
				hint: localizableStrings.CurrentWeekCaption,
				imageConfig: localizableImages.WeekPeriodButtonImage,
				markerValue: "week",
				classes: {
					wrapperClass: ["day-period-fixed-filter-wrapper-class"],
					imageClass: ["period-fixed-filter-image-class"]
				},
				visible: {bindTo: "weekButtonVisible"}
			});
			var monthButton = getFixedButtonBaseConfig({
				imageConfig: localizableImages.MonthPeriodButtonImage,
				hint: localizableStrings.SelectPeriodCaption,
				markerValue: "month",
				classes: {
					imageClass: ["period-fixed-filter-image-class"]
				},
				visible: {bindTo: "monthButtonVisible"}
			});
			monthButton.menu = {
				items: [{
					className: "Terrasoft.MenuItem",
					caption: localizableStrings.YesterdayCaption,
					click: {bindTo: "setPeriod"},
					tag: filterName + "_Yesterday"
				}, {
					className: "Terrasoft.MenuItem",
					caption: localizableStrings.TodayCaption,
					click: {bindTo: "setPeriod"},
					tag: filterName + "_Today"
				}, {
					className: "Terrasoft.MenuItem",
					caption: localizableStrings.TomorrowCaption,
					click: {bindTo: "setPeriod"},
					tag: filterName + "_Tomorrow"
				}, {
					className: "Terrasoft.MenuSeparator"
				}, {
					className: "Terrasoft.MenuItem",
					caption: localizableStrings.PastWeekCaption,
					click: {bindTo: "setPeriod"},
					tag: filterName + "_PastWeek"
				}, {
					className: "Terrasoft.MenuItem",
					caption: localizableStrings.CurrentWeekCaption,
					click: {bindTo: "setPeriod"},
					tag: filterName + "_CurrentWeek"
				}, {
					className: "Terrasoft.MenuItem",
					caption: localizableStrings.NextWeekCaption,
					click: {bindTo: "setPeriod"},
					tag: filterName + "_NextWeek"
				}, {
					className: "Terrasoft.MenuSeparator"
				}, {
					className: "Terrasoft.MenuItem",
					caption: localizableStrings.PastMonthCaption,
					click: {bindTo: "setPeriod"},
					tag: filterName + "_PastMonth"
				}, {
					className: "Terrasoft.MenuItem",
					caption: localizableStrings.CurrentMonthCaption,
					click: {bindTo: "setPeriod"},
					tag: filterName + "_CurrentMonth"
				}, {
					className: "Terrasoft.MenuItem",
					caption: localizableStrings.NextMonthCaption,
					click: {bindTo: "setPeriod"},
					tag: filterName + "_NextMonth"
				}]
			};
			return [dayButton, weekButton, monthButton];
		}

 

In FixedFilterViewModelV2 we see the below functions

 

        function setCurrentDayPeriod() {
			this.setPeriod("PeriodFilter_Today");
		}
 
		function setCurrentWeekPeriod() {
			this.setPeriod("PeriodFilter_CurrentWeek");
		}
 
		function setPeriod(tag) {
			if (!tag) {
				return;
			}
			var indexOfSeparator = tag.lastIndexOf("_");
			if (indexOfSeparator === -1) {
				return;
			}
			var filterName = tag.substring(0, indexOfSeparator);
			var periodName = tag.substring(indexOfSeparator + 1);
			var periodFilterConfig;
			Terrasoft.each(this.config.filters, function(filterConfig) {
				if (filterConfig.name === filterName) {
					periodFilterConfig = this.getPeriodFilterConfig(filterConfig);
				}
			}, this);
			if (!periodFilterConfig) {
				return;
			}
			var startDate = new Date();
			var dueDate;
			switch (periodName) {
				case "Yesterday":
					startDate = Terrasoft.startOfDay(Ext.Date.add(startDate, "d", -1));
					dueDate = Terrasoft.endOfDay(startDate);
					break;
				case "Tomorrow":
					startDate = Terrasoft.startOfDay(Ext.Date.add(startDate, "d", 1));
					dueDate = Terrasoft.endOfDay(startDate);
					break;
				case "PastWeek":
					startDate = Terrasoft.startOfWeek(Ext.Date.add(startDate, "d", -7));
					dueDate = Terrasoft.endOfWeek(startDate);
					break;
				case "CurrentWeek":
					startDate = Terrasoft.startOfWeek(startDate);
					dueDate = Terrasoft.endOfWeek(startDate);
					break;
				case "NextWeek":
					startDate = Terrasoft.startOfWeek(Ext.Date.add(startDate, "d", 7));
					dueDate = Terrasoft.endOfWeek(startDate);
					break;
				case "PastMonth":
					startDate = Terrasoft.startOfMonth(Ext.Date.add(startDate, "mo", -1));
					dueDate = Terrasoft.endOfMonth(startDate);
					break;
				case "CurrentMonth":
					startDate = Terrasoft.startOfMonth(startDate);
					dueDate = Terrasoft.endOfMonth(startDate);
					break;
				case "NextMonth":
					startDate = Terrasoft.startOfMonth(Ext.Date.add(startDate, "mo", 1));
					dueDate = Terrasoft.endOfMonth(startDate);
					break;
				default:
					startDate = Terrasoft.startOfDay(startDate);
					dueDate = Terrasoft.endOfDay(startDate);
					break;
			}
			this.suspendUpdate = true;
			this.set(periodFilterConfig.startDateColumnName, startDate);
			this.set(periodFilterConfig.dueDateColumnName, dueDate);
			this.suspendUpdate = false;
			if (this.filterChanged) {
				this.filterChanged();
			}
		}

In SetPeriod() function we call Terrasoft.startOfWeek & Terrasoft.endOfWeek based on Switch Case, which is responsible for sunday to Saturday filter display (calculations).



In DateUtils.js, we see the below

Terrasoft.utils.date.startOfWeek = function(dateValue) {
	var dateDiff = dateValue.getDay() + (1 - Terrasoft.Resources.CultureSettings.startDay);
	dateDiff = dateDiff ? 1 - dateDiff : -6;
	return Terrasoft.startOfDay(Ext.Date.add(dateValue, Ext.Date.DAY, dateDiff));
};
 
 
Terrasoft.utils.date.endOfWeek = function(dateValue) {
	var dateDiff = dateValue.getDay()  + (1 - Terrasoft.Resources.CultureSettings.startDay);
	dateDiff = dateDiff ? 7 - dateDiff : dateDiff;
	return Terrasoft.endOfDay(Ext.Date.add(dateValue, Ext.Date.DAY, dateDiff));
};





Please guide on how to replace or extend these modules and achieve a week value from "Sunday to Saturday into Monday to Sunday".



Note:

we could not replace these modules (FixedFilterViewModelV2,FixedFilterViewV2)

 by using "Replacing client Module", if we do so we get below error,

Please guide on how to extend and where to consume the extended module and procedure.







Thanks in Advance!

 





Regards,

Bhoobalan P.

Like 0

Like

5 comments

Hi Bhoobalan,

 

The beginning of the week is connected to the system user localization and as you correctly pointed the main logic is stored in the DateUtils.js file. The only way to modify this logic is to modify the content of two functions: startOfWeek and endOfWeek in the following manner:

Terrasoft.utils.date.startOfWeek = function(dateValue) {
    var dateDiff = dateValue.getDay() + (Terrasoft.Resources.CultureSettings.startDay);
    dateDiff = dateDiff ? 1 - dateDiff : -6;
    return Terrasoft.startOfDay(Ext.Date.add(dateValue, Ext.Date.DAY, dateDiff));
};
 
...
 
Terrasoft.utils.date.endOfWeek = function(dateValue) {
	var dateDiff = dateValue.getDay()  + (Terrasoft.Resources.CultureSettings.startDay);
	dateDiff = dateDiff ? 7 - dateDiff : dateDiff;
	return Terrasoft.endOfDay(Ext.Date.add(dateValue, Ext.Date.DAY, dateDiff));
};

Once done the application should be restarted, the application pool recycled and the Redis flushed. As a result the week will start on Monday as needed.

 

Best regards,

Oscar

Please also note that you won't be able to do that from the application UI and it should be done directly in the file (located at root_app_path\Terrasoft.WebApp\Resources\ui\Terrasoft\utils\common directory). If you want to do this in the cloud-based app you need to provide us with the file, directory and application name where this should be done.

 

UPD: logic described here won't work in the cloud based apps because of the bundling service in the cloud.

 

Best regards.

Oscar

And also you need to delete browser cookies for the website and clean cache in the browser so changes could be applied in the browser.

 

Best regards,

Oscar

Oscar Dylan,

Thanks much!

Hello Oleg Drobina,

 

I have indeed followed all the steps below but no changes have been reflected on the date calendar. Have you updated the procedure ever since ? 

 

Thanks,

Show all comments