Add a new column to the Support Case List in my-account

We can add a new column to the case list on the my-account page by extending the function as shown below. The value displayed in the new column is from the case record field ‘Type of Inquiry’.

CaseListView = CaseListView.CaseListView;
_.extend(CaseListView.prototype, {
	getChildViews: _.wrap(CaseListView.prototype.getChildViews, function(fn) {
		var original_Ret = fn.apply(this, _.toArray(arguments).slice(1));
		original_Ret["Case.List.Items"] = function() {
			var records_collection = new Backbone.Collection(this.collection.map(function(current_case) {
				console.log("current_case", current_case);
				return new Backbone.Model({
					touchpoint: 'customercenter',
					title: _('Case #$(0)').translate(current_case.get('caseNumber')),
					detailsURL: '#/cases/' + current_case.get('internalid'),
					internalid: current_case.get('internalid'),
					columns: [{
						label: _('Subject:').translate(),
						type: 'subject',
						name: 'subject',
						value: current_case.get('title')
					}, {
						label: _('Creation Date:').translate(),
						type: 'creation-date',
						name: 'creation-date',
						value: current_case.get('createdDate').split(' ')[0]
					}, {
						label: _('Last Message:').translate(),
						type: 'date',
						name: 'last-message',
						value: current_case.get('lastMessageDate').split(' ')[0]
					}, {
						label: _('Status:').translate(),
						type: 'status',
						name: 'status',
						value: _.isObject(current_case.get('status')) ? current_case.get('status').name : current_case.get('status').name
					}, {
						label: _('Type of Inquiry:').translate(),
						type: 'inquiry',
						name: 'inquiry',
						value: _.isObject(current_case.get('category')) ? current_case.get('category').name : current_case.get('category').name
					}]
				});
			}));
			return new BackboneCollectionView({
				childView: RecordViewsView,
				collection: records_collection,
				viewsPerRow: 1
			});
		}
		return original_Ret;
	}),
});

To add the heading for the new column, the corresponding template needs to be updated.

Note: Since the RecordViewsView is used for most of the lists on the my-account page, we can’t update that view.

Leave a comment

Your email address will not be published. Required fields are marked *