Article

Agent desktop. Group queue items by queue instead of entity

Case description:

In agent desktop group queue item tabs by queue (see Figure 1).

 

Figure 1. Agent desktop

Algorithm of realization:

  1. Create replacing client schema of OperatorQueues (must be inherited from "Schema - Agent queues")
  2. Override loadQueues, queueTabChange and createQueuesTabs methods as following:

    define("OperatorQueues", ["terrasoft"],
        function (Terrasoft) {
            return {
                attributes: {},
                methods: {
                    loadQueues: function (callback) {
                        var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
                            rootSchemaName: "Queue"
                        });
                        esq.isDistinct = true;
                        esq.addColumn("Id");
                        esq.addColumn("Name");
                        esq.addColumn("QueueEntitySchema");
                        esq.addColumn("[SysSchema:UId:QueueEntitySchema].Name", "EntitySchemaName");
                        esq.addColumn("[QueueObject:EntitySchemaUId:QueueEntitySchema].IsClosedQueue", "IsClosedQueue");
                        this.appendOperatorFilters(esq);
                        this.addQueueInProgressFilters(esq);
                        esq.getEntityCollection(function (result) {
                            if (!result.success) {
                                callback();
                            }
                            callback(result.collection);
                        });
                    },
                    queueTabChange: function (activeTab) {
                        var queueId = activeTab.get("Id");
                        var entitySchemaUId = activeTab.get("EntitySchemaUId");
                        var entitySchemaName = activeTab.get("EntitySchemaName");
                        var isClosedQueue = activeTab.get("IsClosedQueue");
                        var loadModuleCallback = function () {
                            this.sandbox.loadModule("QueueModule", {
                                renderTo: "operatorQueueEntityContainer",
                                parameters: {
                                    QueueId: queueId,
                                    EntitySchemaUId: entitySchemaUId,
                                    EntitySchemaName: entitySchemaName,
                                    IsClosedQueue: isClosedQueue
                                }
                            });
                        }.bind(this);
                        var profile = this.get("Profile");
                        if (profile.activeEntitySchemaUId !== entitySchemaUId) {
                            profile.activeEntitySchemaUId = entitySchemaUId;
                            this.saveProfileData(loadModuleCallback);
                        } else {
                            loadModuleCallback.call();
                        }
                    },
                    createQueuesTabs: function (collection) {
                        var activeQueueTabName = null;
                        if (!collection) {
                            return;
                        }
                        var profile = this.get("Profile");
                        var savedActiveEntitySchemaUId = profile.activeEntitySchemaUId;
                        var queues = this.get("Queues");
                        queues.clear();
                        collection.each(function (item) {
                            var queueId = item.get("Id");
                            var queueName = item.get("Name");
                            var queueEntitySchema = item.get("QueueEntitySchema");
                            var queueEntitySchemaName = item.get("EntitySchemaName");
                            var isClosedQueue = item.get("IsClosedQueue");
                            if (queueEntitySchema) {
                                var queueUId = queueEntitySchema.value;
                                var queueCaption = queueName;
                                var name = this.getQueueTabName(queueId);
                                queues.add(queueId, Ext.create("Terrasoft.BaseViewModel", {
                                    values: {
                                        Id: queueId,
                                        Caption: queueCaption,
                                        Name: name,
                                        EntitySchemaUId: queueUId,
                                        EntitySchemaName: queueEntitySchemaName,
                                        IsClosedQueue: isClosedQueue
                                    }
                                }));
                                if (queueId === savedActiveEntitySchemaUId) {
                                    activeQueueTabName = this.getQueueTabName(savedActiveEntitySchemaUId);
                                } else if (Ext.isEmpty(activeQueueTabName)) {
                                    activeQueueTabName = name;
                                }
                            }
                        }, this);
                        this.set("ActiveQueueTabName", activeQueueTabName);
                    }
                },
                diff: []
            };
        }
    );

     

Like 0

Like

Share

0 comments
Show all comments