/*! VMCapo.js */var Module;
(function (Module) {
    var Capo;
    (function (Capo) {
        var VMCapo = /** @class */ (function () {
            function VMCapo() {
            }
            return VMCapo;
        }());
        Capo.VMCapo = VMCapo;
    })(Capo = Module.Capo || (Module.Capo = {}));
})(Module || (Module = {}));
//VMCapo.js.map;
/*! VMCapoLink.js */var Module;
(function (Module) {
    var Capo;
    (function (Capo) {
        var VMCapoLink = /** @class */ (function () {
            function VMCapoLink() {
            }
            return VMCapoLink;
        }());
        Capo.VMCapoLink = VMCapoLink;
    })(Capo = Module.Capo || (Module.Capo = {}));
})(Module || (Module = {}));
//VMCapoLink.js.map;
/*! VMEvent.js */var Module;
(function (Module) {
    var CMS;
    (function (CMS) {
        var VMEvent = /** @class */ (function () {
            function VMEvent() {
            }
            return VMEvent;
        }());
        CMS.VMEvent = VMEvent;
    })(CMS = Module.CMS || (Module.CMS = {}));
})(Module || (Module = {}));
//VMEvent.js.map;
/*! VMEventTranslation.js */var Module;
(function (Module) {
    var CMS;
    (function (CMS) {
        var VMEventTranslation = /** @class */ (function () {
            function VMEventTranslation() {
            }
            return VMEventTranslation;
        }());
        CMS.VMEventTranslation = VMEventTranslation;
    })(CMS = Module.CMS || (Module.CMS = {}));
})(Module || (Module = {}));
//VMEventTranslation.js.map;
/*! VMEventType.js */var Module;
(function (Module) {
    var CMS;
    (function (CMS) {
        var VMEventType = /** @class */ (function () {
            function VMEventType() {
            }
            return VMEventType;
        }());
        CMS.VMEventType = VMEventType;
    })(CMS = Module.CMS || (Module.CMS = {}));
})(Module || (Module = {}));
//VMEventType.js.map;
/*! VMEventTypeTranslation.js */var Module;
(function (Module) {
    var CMS;
    (function (CMS) {
        var VMEventTypeTranslation = /** @class */ (function () {
            function VMEventTypeTranslation() {
            }
            return VMEventTypeTranslation;
        }());
        CMS.VMEventTypeTranslation = VMEventTypeTranslation;
    })(CMS = Module.CMS || (Module.CMS = {}));
})(Module || (Module = {}));
//VMEventTypeTranslation.js.map;
/*! VMFeedDetail.js */var Module;
(function (Module) {
    var Rss;
    (function (Rss) {
        var VMFeedDetail = /** @class */ (function () {
            function VMFeedDetail() {
            }
            return VMFeedDetail;
        }());
        Rss.VMFeedDetail = VMFeedDetail;
    })(Rss = Module.Rss || (Module.Rss = {}));
})(Module || (Module = {}));
//VMFeedDetail.js.map;
/*! VMFeedItem.js */var Module;
(function (Module) {
    var Rss;
    (function (Rss) {
        var VMFeedItem = /** @class */ (function () {
            function VMFeedItem() {
            }
            return VMFeedItem;
        }());
        Rss.VMFeedItem = VMFeedItem;
    })(Rss = Module.Rss || (Module.Rss = {}));
})(Module || (Module = {}));
//VMFeedItem.js.map;
/*! VMFeedSmall.js */var Module;
(function (Module) {
    var Rss;
    (function (Rss) {
        var VMFeedSmall = /** @class */ (function () {
            function VMFeedSmall() {
            }
            return VMFeedSmall;
        }());
        Rss.VMFeedSmall = VMFeedSmall;
    })(Rss = Module.Rss || (Module.Rss = {}));
})(Module || (Module = {}));
//VMFeedSmall.js.map;
/*! VMFeedSource.js */var Module;
(function (Module) {
    var Rss;
    (function (Rss) {
        var VMFeedSource = /** @class */ (function () {
            function VMFeedSource() {
            }
            return VMFeedSource;
        }());
        Rss.VMFeedSource = VMFeedSource;
    })(Rss = Module.Rss || (Module.Rss = {}));
})(Module || (Module = {}));
//VMFeedSource.js.map;
/*! CapoDetailController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var CapoModule;
(function (CapoModule) {
    var CapoDetailController = /** @class */ (function (_super) {
        __extends(CapoDetailController, _super);
        function CapoDetailController($scope, $http) {
            var _this = _super.call(this, $scope, $http) || this;
            var controller = _this;
            $scope.CapoId = $scope.urlVars[5];
            $scope.searchServiceName = "Capo";
            $scope.getDetail = function (capoId) {
                console.log(capoId);
                controller.CallGetAction('capo', 'detail', capoId, function (data) {
                    $scope.event = data.Data;
                    $scope.safeApply();
                }, null, null, true);
            };
            if ($scope.CapoId != null && $scope.CapoId != undefined)
                $scope.getDetail($scope.CapoId);
            $scope.doSave = function () {
                console.log("Save");
                controller.CallPostAction('capo', 'save', null, $scope.event, function (data) {
                    $scope.event = data.Data;
                    location.href = "/en/common/capo/detail/" + data.Data.CapoId;
                }, null, null, true);
            };
            $scope.doAdd = function () {
                console.log("doAdd");
                var link = new Module.Capo.VMCapoLink();
                link.CapoId = $scope.CapoId;
                link.LinkText = $scope.Text;
                link.LinkUrl = $scope.Link;
                $scope.event.Links.push(link);
                $scope.Text = "";
                $scope.Link = "";
            };
            $scope.doRemove = function (index) {
                console.log("doRemove");
                $scope.event.Links.splice(index, 1);
            };
            $scope.doMoveUp = function (index) {
                console.log("doMoveUp");
                moveItem(index, index - 1);
            };
            $scope.doMoveDown = function (index) {
                console.log("doMoveDown");
                moveItem(index, index + 1);
            };
            function moveItem(from, to) {
                // remove `from` item and store it
                var f = $scope.event.Links.splice(from, 1)[0];
                // insert stored item into position `to`
                $scope.event.Links.splice(to, 0, f);
            }
            return _this;
        }
        return CapoDetailController;
    }(BaseModule.BaseController));
    CapoModule.CapoDetailController = CapoDetailController;
})(CapoModule || (CapoModule = {}));
angular.module('minervaApp').controller("CapoModule.CapoDetailController", ["$scope", "$http", CapoModule.CapoDetailController]);
//CapoDetailController.js.map;
/*! CapoListController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var CapoModule;
(function (CapoModule) {
    var CapoListController = /** @class */ (function (_super) {
        __extends(CapoListController, _super);
        function CapoListController($scope, $http, $timeout) {
            var _this = this;
            $scope.searchServiceName = "Capo";
            _this = _super.call(this, $scope, $http, false) || this;
            var controller = _this;
            $scope.resetSearch = function () {
                //    console.log("resetSearch");
                $scope.keywords = "";
                $scope.country = "";
                $scope.yfrom = "";
                $scope.yto = "";
                $scope.domain = "";
                $scope.RecordPerPage = 20;
                $scope.results = [];
                $scope.page = 1;
                $scope.list();
            };
            $scope.doSearch = function () {
                //    console.log("doSearch");
                $scope.RecordPerPage = 20;
                $scope.results = [];
                $scope.page = 1;
                $scope.list();
            };
            $scope.loadMore = function () {
                if ($scope.page < $scope.paging.maxPages) {
                    $scope.page++;
                    $scope.list($scope.page);
                }
            };
            $scope.openDetail = function (capoId) {
                location.href = "detail/" + capoId;
            };
            $scope.openEdit = function (capoId) {
                location.href = "edit/" + capoId;
            };
            $scope.openNew = function () {
                location.href = "edit";
            };
            $scope.list = function (pageNr) {
                if (pageNr === void 0) { pageNr = null; }
                if (pageNr == null || pageNr < 1)
                    pageNr = 1;
                // add searching parameter to query string
                var query = "";
                query = query + "&currentPage=" + pageNr;
                query = query + "&rpp=" + $scope.RecordPerPage;
                query = query + "&sortby=" + $scope.sortSelectedItem;
                query = query + "&sortdir=" + $scope.sortDirection;
                if ($scope.keywords != null && $scope.keywords != undefined)
                    query = query + "&keywords=" + $scope.keywords;
                if ($scope.country != null && $scope.country != undefined)
                    query = query + "&country=" + $scope.country;
                if ($scope.yfrom != null && $scope.yfrom != undefined)
                    query = query + "&yfrom=" + $scope.yfrom;
                if ($scope.yto != null && $scope.yto != undefined)
                    query = query + "&yto=" + $scope.yto;
                if ($scope.domain != null && $scope.domain != undefined)
                    query = query + "&domain=" + $scope.domain;
                controller.List($scope.searchServiceName, function (data) {
                    var searchResult = data.Data;
                    $scope.paging.maxPages = searchResult.maxPages;
                    $scope.paging.currentPage = searchResult.currentPage;
                    $scope.paging.totlaResults = searchResult.totlaResults;
                    $scope.paging.GetSelectablePages();
                    Array.prototype.push.apply($scope.results, searchResult.resultSet);
                    // = $scope.results.join(  ); 
                }, null, true, query);
            };
            $scope.doSearch();
            return _this;
        }
        return CapoListController;
    }(SearchModule.GenericSearchController));
    CapoModule.CapoListController = CapoListController;
})(CapoModule || (CapoModule = {}));
angular.module('minervaApp').controller("CapoModule.CapoListController", ["$scope", "$http", CapoModule.CapoListController]);
//CapoListController.js.map;
/*! ForumDetailController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
/// <reference path='../../tsmodels/Admin/Forum/VMForum.ts' /> 
var ForumViewerModule;
(function (ForumViewerModule) {
    var ForumDetailController = /** @class */ (function (_super) {
        __extends(ForumDetailController, _super);
        function ForumDetailController($scope, $http) {
            var _this = _super.call(this, $scope, $http) || this;
            var controller = _this;
            $scope.ForumId = $scope.urlVars[6];
            $scope.WorkingAreaUrlId = $scope.urlVars[3];
            var resetNewThread = function () {
                $scope.NewThreadWinOpened = false;
                $scope.NewThread.ThreadText = '';
                $scope.NewThread.ThreadTitle = '';
                $scope.NewThread = null;
            };
            // Compute the thread popularity
            var computeThreadPopularity = function (threada, threadb) {
                // For now it is simply the number of answer plus the number of views
                // We need to add something about last activity date
                var pointa = threada.NumberOfAnswers + threada.Views;
                var pointb = threadb.NumberOfAnswers + threadb.Views;
                return pointa > pointb ? -1 :
                    (pointa == pointb ? (threada.LastDate > threadb.LastDate ? -1 : 1) : 1);
            };
            var prepareThreads = function () {
                // Show the popular threads only if we have enaugth elements
                if ($scope.Forum.Threads != null &&
                    $scope.Forum.Threads.length >= $scope.Forum.MinimumThreadList + $scope.Forum.MostPopularNumber) {
                    // Make a copy of original Thread Array in $scope.OtherThreads
                    $scope.OtherThreads = [];
                    for (var i = 0; i < $scope.Forum.Threads.length; i++) {
                        $scope.OtherThreads.push($scope.Forum.Threads[i]);
                    }
                    // Sort the original thread
                    $scope.Forum.Threads.sort(function (a, b) {
                        return computeThreadPopularity(a, b);
                    });
                    // Copy the MostPopularNumber elements to PopularThreads
                    $scope.PopularThreads = [];
                    for (var i = 0; i < $scope.Forum.MostPopularNumber; i++) {
                        $scope.PopularThreads.push($scope.Forum.Threads[i]);
                        // Delete added thread form OtherThreads
                        for (var ii = 0; ii < $scope.OtherThreads.length; ii++) {
                            if ($scope.OtherThreads[ii].ThreadId == $scope.Forum.Threads[i].ThreadId) {
                                $scope.OtherThreads.splice(ii, 1);
                                //console.log('removed item ' + ii);
                            }
                        }
                    }
                }
                else {
                    $scope.OtherThreads = $scope.Forum.Threads;
                }
            };
            $scope.getForum = function (forumId) {
                controller.CallWAGetAction('forum', 'GetForumWithThreads', $scope.WorkingAreaUrlId, [forumId], function (data) {
                    $scope.Forum = Module.VMSearchResult = data.Data;
                    prepareThreads();
                    if ($scope.NewThread) {
                        resetNewThread();
                    }
                    $scope.safeApply();
                }, null, true);
            };
            $scope.openNewThreadWin = function () {
                if (!$scope.NewThread || $scope.NewThread == null) {
                    $scope.NewThread = new Module.Admin.Forum.VMForumThread();
                }
                $scope.NewThreadWinCollapsed = false;
                $scope.NewThreadWinOpened = true;
            };
            $scope.closeNewThreadWin = function () {
                resetNewThread();
            };
            $scope.flipNewThreadWin = function () {
                $scope.NewThreadWinCollapsed = !$scope.NewThreadWinCollapsed;
            };
            $scope.addThread = function () {
                var title = "Adding thread error";
                if ($scope.NewThread.ThreadTitle == null) {
                    MessagesModule.MessagesController.prototype.ShowMessageBox('Specify a title.', MessagesModule.MessageBoxType.ERROR, title);
                    return;
                }
                var message = 'Some errors occur addin new thread.';
                $scope.NewThread.ForumId = $scope.Forum.ForumId;
                $scope.NewThread.Views = 0;
                controller.CallWAPostAction('forum', 'SaveThread', $scope.WorkingAreaUrlId, [$scope.NewThread.ForumId], $scope.NewThread, function (data) {
                    $scope.getForum($scope.ForumId);
                }, function () { return MessagesModule.MessagesController.prototype.ShowMessageBox(message, MessagesModule.MessageBoxType.ERROR, title); }, null);
            };
            $scope.NewThread = null;
            $scope.NewThreadWinOpened = false;
            $scope.safeApply();
            $scope.getForum($scope.ForumId);
            return _this;
        }
        return ForumDetailController;
    }(BaseModule.BaseController));
    ForumViewerModule.ForumDetailController = ForumDetailController;
})(ForumViewerModule || (ForumViewerModule = {}));
angular.module('minervaApp').controller("ForumViewerModule.ForumDetailController", ["$scope", "$http", ForumViewerModule.ForumDetailController]);
//ForumDetailController.js.map;
/*! ForumThreadController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
/// <reference path='../../tsmodels/Admin/Forum/VMForum.ts' /> 
var ForumThreadModule;
(function (ForumThreadModule) {
    var ForumThreadController = /** @class */ (function (_super) {
        __extends(ForumThreadController, _super);
        function ForumThreadController($scope, $http) {
            var _this = _super.call(this, $scope, $http, "Common", "ForumViewer", false) || this;
            var controller = _this;
            $scope.WorkingAreaUrlId = $scope.urlVars[3];
            $scope.ForumId = $scope.urlVars[6];
            $scope.ThreadId = $scope.urlVars[7];
            $scope.getThread = function (threadId) {
                if ($scope.NewThread) {
                    resetNewThread();
                }
                controller.CallWAGetAction('forum', 'GetThread', $scope.WorkingAreaUrlId, [threadId], function (data) {
                    $scope.Thread = Module.VMSearchResult = data.Data;
                    controller.CallWAGetAction('forum', 'GetAnswers', $scope.WorkingAreaUrlId, [threadId], function (data) {
                        $scope.Answers = Module.VMSearchResult = data.Data;
                    }, null, true);
                }, null, true);
            };
            $scope.replyThread = function () {
                var message = 'Some errors occur addin new thread.';
                var title = "Adding thread error";
                $scope.NewThread.ForumId = $scope.Thread.ForumId;
                $scope.NewThread.Parent = $scope.Thread.ThreadId;
                $scope.NewThread.Answer = $scope.AnsweringToThreadId;
                $scope.NewThread.Views = 0;
                //Decoupling merge with rev. 4300
                //controller.CallWAPostAction('forum', 'SaveThread', $scope.WorkingAreaUrlId, [$scope.Thread.ForumId], $scope.NewThread, (data: Module.VMResult) => {
                controller.CallWAPostAction('forum', 'SaveThread', $scope.WorkingAreaUrlId, [$scope.Thread.ThreadId], $scope.NewThread, function (data) {
                    //END Decoupling merge with rev. 4300
                    $scope.getThread($scope.ThreadId);
                }, function () { return MessagesModule.MessagesController.prototype.ShowMessageBox(message, MessagesModule.MessageBoxType.ERROR, title); }, true);
            };
            $scope.incrementThreadViews = function (threadId) {
                controller.CallWAGetAction('forum', 'incrementThreadViews', $scope.WorkingAreaUrlId, [threadId], function (data) {
                    $scope.getThread($scope.ThreadId);
                }, null, false);
            };
            var resetNewThread = function () {
                $scope.NewThreadWinOpened = false;
                $scope.NewThread.ThreadText = '';
                $scope.NewThread.ThreadTitle = '';
                $scope.AnsweringToThreadId = null;
                $scope.NewThread = null;
            };
            $scope.openNewThreadWin = function (AnswerToThreadId) {
                if (!$scope.NewThread || $scope.NewThread == null) {
                    $scope.NewThread = new Module.Admin.Forum.VMForumThread();
                }
                $scope.NewThreadWinCollapsed = false;
                $scope.AnsweringToThreadId = AnswerToThreadId;
                $scope.NewThreadWinOpened = true;
            };
            $scope.closeNewThreadWin = function () {
                resetNewThread();
            };
            $scope.flipNewThreadWin = function () {
                $scope.NewThreadWinCollapsed = !$scope.NewThreadWinCollapsed;
            };
            $scope.NewThread = null;
            $scope.NewThreadWinOpened = false;
            $scope.safeApply();
            $scope.incrementThreadViews($scope.ThreadId);
            return _this;
        }
        return ForumThreadController;
    }(BaseModule.CrudBaseController));
    ForumThreadModule.ForumThreadController = ForumThreadController;
})(ForumThreadModule || (ForumThreadModule = {}));
angular.module('minervaApp').controller("ForumThreadModule.ForumThreadController", ["$scope", "$http", ForumThreadModule.ForumThreadController]);
//ForumThreadController.js.map;
/*! ForumViewerController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
/// <reference path='../../tsmodels/Admin/Forum/VMForum.ts' /> 
var ForumViewerModule;
(function (ForumViewerModule) {
    var ForumViewerController = /** @class */ (function (_super) {
        __extends(ForumViewerController, _super);
        function ForumViewerController($scope, $http) {
            var _this = _super.call(this, $scope, $http) || this;
            var controller = _this;
            $scope.WorkingAreaUrlId = $scope.urlVars[3];
            $scope.list = function () {
                controller.CallWAGetAction('forum', 'ListMyForums', $scope.WorkingAreaId, null, function (data) {
                    $scope.Forums = Module.VMSearchResult = data.Data;
                }, null, true);
            };
            if ($scope.WorkingAreaId == null || $scope.WorkingAreaId == '' || $scope.WorkingAreaId == 'undefined') {
                $scope.getWorkingAreaId = function (pageNr) {
                    if (pageNr === void 0) { pageNr = null; }
                    controller.CallGetAction('WorkingArea', 'getbyurlid', $scope.WorkingAreaUrlId, function (data) {
                        var wa = data.Data;
                        if (wa)
                            $scope.WorkingAreaId = wa.WorkingAreaId;
                        else
                            $scope.WorkingAreaId = '';
                        $scope.list();
                    });
                };
                $scope.getWorkingAreaId();
            }
            else
                $scope.list();
            return _this;
        }
        return ForumViewerController;
    }(BaseModule.BaseController));
    ForumViewerModule.ForumViewerController = ForumViewerController;
})(ForumViewerModule || (ForumViewerModule = {}));
angular.module('minervaApp').controller("ForumViewerModule.ForumViewerController", ["$scope", "$http", ForumViewerModule.ForumViewerController]);
//ForumViewerController.js.map;
/*! MinervaController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var MinervaModule;
(function (MinervaModule) {
    /**********************************   DASHBOARD CONTROLLER ********************************************/
    // Controller to manage minerva dashboard form
    var DashboardController = /** @class */ (function (_super) {
        __extends(DashboardController, _super);
        function DashboardController($scope, $http) {
            var _this = _super.call(this, $http, $scope) || this;
            var controller = _this;
            $scope.getDashboardInfo = function () {
                controller.CallGetAction("Minerva", "GetBashboardInfo", null, function (data) {
                    $scope.DashBoardInfo = data.Data;
                });
            };
            $scope.getDashboardInfo();
            return _this;
        }
        return DashboardController;
    }(HttpModule.HttpController));
    MinervaModule.DashboardController = DashboardController;
})(MinervaModule || (MinervaModule = {}));
angular.module('minervaApp').controller("MinervaModule.DashboardController", ["$scope", "$http", MinervaModule.DashboardController]);
//MinervaController.js.map;
/*! QueueManagementController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var QueueManagementModule;
(function (QueueManagementModule) {
    // Controller to manage queue management search form
    var QueueManagementSearchController = /** @class */ (function (_super) {
        __extends(QueueManagementSearchController, _super);
        function QueueManagementSearchController($scope, $http, $timeout) {
            var _this = this;
            $scope.isAlreadyRunning = false;
            $scope.IsBroken = true;
            $scope.IsDone = true;
            $scope.IsKilled = true;
            $scope.IsQuit = true;
            $scope.IsRetry = true;
            $scope.IsRunning = true;
            $scope.IsToKill = true;
            $scope.IsTodo = true;
            ///////// Initialize record per page number and set the default value from web config ///////////////////
            $scope.RecordPerPageList = [{
                    PageNum: 5,
                    sPageNum: "5"
                },
                {
                    PageNum: 10,
                    sPageNum: "10"
                }, {
                    PageNum: 20,
                    sPageNum: "20"
                },
                {
                    PageNum: 50,
                    sPageNum: "50"
                }
            ];
            $scope.RecordPerPage = $scope.RecordPerPageList[0].PageNum;
            try {
                $scope.DefaultRecordPerPage = parseInt($("#rpp_def").val());
                if (($scope.DefaultRecordPerPage % 5) != 0)
                    $scope.DefaultRecordPerPage = 20;
                var i = 0;
                for (i = 0; i < $scope.RecordPerPageList.length; i++) {
                    if ($scope.DefaultRecordPerPage == $scope.RecordPerPageList[i].PageNum) {
                        $scope.RecordPerPage = $scope.RecordPerPageList[i].PageNum;
                        break;
                    }
                }
            }
            catch (e) { }
            $scope.paging = new PagingModule.PagingController();
            ///////// END Initialize record per page number and set the default value from web config ///////////////////
            _this = _super.call(this, $http, $scope) || this;
            var controller = _this;
            // Method called to search tasks
            $scope.queueSearch = function (pageNr) {
                if (pageNr === void 0) { pageNr = null; }
                if (pageNr == null || pageNr < 1)
                    pageNr = 1;
                // add searching parameter to query string
                var query = "";
                query = query + "searchingtext=" + ($scope.SearchingText != undefined ? encodeURIComponent($scope.SearchingText) : '');
                //query = query + "&lifecycleCriteria=" + ($scope.lifecycleCriteria != undefined ? $scope.lifecycleCriteria : '');
                query = query + "&broken=" + ($scope.IsBroken ? 'true' : 'false');
                query = query + "&done=" + ($scope.IsDone ? 'true' : 'false');
                query = query + "&killed=" + ($scope.IsKilled ? 'true' : 'false');
                query = query + "&quit=" + ($scope.IsQuit ? 'true' : 'false');
                query = query + "&retry=" + ($scope.IsRetry ? 'true' : 'false');
                query = query + "&running=" + ($scope.IsRunning ? 'true' : 'false');
                query = query + "&tokill=" + ($scope.IsToKill ? 'true' : 'false');
                query = query + "&todo=" + ($scope.IsTodo ? 'true' : 'false');
                query = query + "&currentPage=" + pageNr;
                query = query + "&rpp=" + $scope.RecordPerPage;
                controller.Search("Queue", query, function (data) {
                    var searchResult = data.Data;
                    // set returned paging parameters
                    $scope.paging.maxPages = searchResult.maxPages;
                    $scope.paging.currentPage = searchResult.currentPage;
                    $scope.paging.totlaResults = searchResult.totlaResults;
                    $scope.paging.GetSelectablePages();
                    $scope.Actions = searchResult.resultSet;
                    $scope.isAlreadyRunning = false;
                    if ($scope.isSelectedAll)
                        $scope.selectAll();
                    $scope.checkViewGroupAction();
                    $scope.estResultsRefresh();
                });
            };
            // reset all search filters and call a news searh
            $scope.resetSearch = function () {
                $scope.paging.currentPage = 1;
                $scope.SearchingText = "";
                $scope.queueSearch();
            };
            // show if hidden or hide if showed, a html control and put the class selected to it
            $scope.showHideDiv = function (id, callerId) {
                if (callerId === void 0) { callerId = null; }
                if ($("#" + id).is(":hidden")) {
                    $("#" + id).show();
                    if (callerId != null) {
                        if (!$("#" + callerId).hasClass("selected")) {
                            $("#" + callerId).addClass("selected");
                        }
                    }
                }
                else {
                    $("#" + id).hide();
                    if (callerId != null) {
                        if ($("#" + callerId).hasClass("selected")) {
                            $("#" + callerId).removeClass("selected");
                        }
                    }
                }
            };
            $scope.killAction = function (id) {
                if (id == null)
                    return;
                var tasks = Array();
                tasks.push(id);
                controller.CallPostAction("Queue", "KillActions", id, tasks, function (data) {
                    $scope.queueSearch();
                });
            };
            $scope.reschedule = function (id) {
                if (id == null)
                    return;
                var tasks = Array();
                tasks.push(id);
                controller.CallPostAction("Queue", "RescheduleActions", id, tasks, function (data) {
                    $scope.queueSearch();
                });
            };
            // select all the shown searched tasks of the list
            $scope.selectAll = function () {
                if ($scope.Actions != null && $scope.Actions.length > 0) {
                    $scope.isSelectedAll = !$scope.isSelectedAll;
                    var i = 0;
                    for (i = 0; i < $scope.Actions.length; i++) {
                        $scope.Actions[i].b_isel = $scope.isSelectedAll;
                    }
                    $scope.viewGroupActionButtons = $scope.isSelectedAll;
                    $scope.isSelectedAllFake = $scope.isSelectedAll;
                }
            };
            // check if the action group buttons are allowed to be shown
            $scope.checkViewGroupAction = function () {
                if ($scope.Actions != null && $scope.Actions.length > 0) {
                    $scope.viewGroupActionButtons = false;
                    var i = 0;
                    for (i = 0; i < $scope.Actions.length; i++) {
                        if ($scope.Actions[i].b_isel) {
                            $scope.viewGroupActionButtons = true;
                        }
                    }
                }
            };
            // consolidate the selected tasks 
            $scope.killSelected = function () {
                if ($scope.Actions != null && $scope.Actions.length > 0) {
                    var i = 0;
                    var tasks = Array();
                    for (i = 0; i < $scope.Actions.length; i++) {
                        if ($scope.Actions[i].b_isel) {
                            tasks.push($scope.Actions[i].Id);
                        }
                    }
                    if (tasks.length > 0) {
                        controller.CallPostAction("Queue", "KillActions", $scope.Actions[0].Id, tasks, function (data) {
                            $scope.queueSearch();
                        });
                    }
                }
            };
            $scope.rescheduleSelected = function () {
                if ($scope.Actions != null && $scope.Actions.length > 0) {
                    var i = 0;
                    var tasks = Array();
                    for (i = 0; i < $scope.Actions.length; i++) {
                        if ($scope.Actions[i].b_isel) {
                            tasks.push($scope.Actions[i].Id);
                        }
                    }
                    if (tasks.length > 0) {
                        controller.CallPostAction("Queue", "RescheduleActions", $scope.Actions[0].Id, tasks, function (data) {
                            $scope.queueSearch();
                        });
                    }
                }
            };
            // if exist return the list of establishment in eleboration ids. Else null.
            $scope.getResultListIfInProgress = function () {
                var i = 0;
                var resultIds = new Array();
                var isInProgress = false;
                for (i = 0; i < $scope.Actions.length; i++) {
                    resultIds.push($scope.Actions[i].Id);
                    if ($scope.Actions[i].b_iielab) {
                        isInProgress = true;
                    }
                }
                if (isInProgress)
                    return resultIds;
                return null;
            };
            // if at least one establishment is in elaboration launch the check results. This is the polling method.
            // The check call is perform till all the establishment are processed and are not in elaboration more
            $scope.estResultsRefresh = function () {
                var resultIds = $scope.getResultListIfInProgress();
                if (resultIds != null && !$scope.isAlreadyRunning) {
                    $timeout(function refreshResults() {
                        $scope.isAlreadyRunning = true;
                        controller.CallPostAction("Queue", "RefreshQueueSearchResults", "", resultIds, function (data) {
                            var searchResult = data.Data;
                            if ($scope.isAlreadyRunning)
                                $scope.Actions = searchResult;
                            var resultIds = $scope.getResultListIfInProgress();
                            if (resultIds != null) {
                                $timeout(refreshResults, 3000);
                            }
                            else {
                                if ($scope.isAlreadyRunning)
                                    $scope.queueSearch($scope.paging.currentPage);
                                $scope.isAlreadyRunning = false;
                            }
                        }, null, null, false);
                    }, 3000);
                }
            };
            $scope.isSelectedAll = false;
            $scope.queueSearch();
            return _this;
            // Load cache data
            //this.GetCache("checktypes", function (data: Module.VMResult) { $scope.CheckTypes = data.Data; });
        }
        return QueueManagementSearchController;
    }(HttpModule.HttpController));
    QueueManagementModule.QueueManagementSearchController = QueueManagementSearchController;
})(QueueManagementModule || (QueueManagementModule = {}));
angular.module('minervaApp').controller("QueueManagementModule.QueueManagementSearchController", ["$scope", "$http", QueueManagementModule.QueueManagementSearchController]);
//QueueManagementController.js.map;
/*! IResourceController.js */;
/*! PartialContentSearch.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var ContentResourceSearchModule;
(function (ContentResourceSearchModule) {
    var MimeOptions = /** @class */ (function () {
        function MimeOptions() {
        }
        // Use of keyword "get" would have been better, but still uncompatible with some browser's versions
        MimeOptions.All = "All";
        MimeOptions.WebContent = "WebContent";
        MimeOptions.Binary = "Binary";
        MimeOptions.Image = "Image";
        return MimeOptions;
    }());
    ContentResourceSearchModule.MimeOptions = MimeOptions;
    var ContentSearchResource = /** @class */ (function (_super) {
        __extends(ContentSearchResource, _super);
        // FUNCTIONS
        //********************************************
        function ContentSearchResource($scope, $http) {
            var _this = this;
            $scope.DeleteVisibility = false;
            $scope.FolderVisibility = false;
            $scope.UnlockVisibility = true;
            $scope.IsDocLibQueryString = "";
            $scope.IsDocumentLibrary = true;
            $scope.IsMenuFilter = false;
            $scope.ShowWASelection = true;
            $scope.searchServiceName = "FileSystem";
            _this = _super.call(this, $scope, $http, true) || this;
            $scope.sortSelectedItem = "LAST_DATE";
            $scope.sortDirection = "DESC";
            var controller = _this;
            // Path for HTML content
            $scope.LinkHTMLPageSelected = "/admin/cms/webpageedit";
            // Path for binary content
            $scope.LinkBinaryPageSelected = "/admin/resources/resourceedit";
            var waId = controller.GetParameterByName('waId');
            $scope.WorkingAreaQueryString = "";
            if (waId != null && waId != '' && waId != 'undefined') {
                $scope.WorkingAreaId = waId;
                $scope.WorkingAreaQueryString = "&waId=" + waId;
            }
            $scope.getSearchQS = function (pageNr, recordPerPage) {
                $scope.FilterType = '';
                if ($scope.MimeOption == ContentResourceSearchModule.MimeOptions.Image) {
                    $scope.FilterType = 'I';
                }
                if ($scope.MimeOption == ContentResourceSearchModule.MimeOptions.WebContent) {
                    $scope.FilterType = 'WC';
                }
                if ($scope.MimeOption == ContentResourceSearchModule.MimeOptions.Binary) {
                    $scope.FilterType = 'B';
                }
                // add searching parameter to query string
                var query = "";
                query = query + "searchingtext=" + ($scope.SearchingText != undefined ? encodeURIComponent($scope.SearchingText) : '');
                //query = query + "&language=" + ($scope.SelectedLanguage != undefined ? $scope.SelectedLanguage : '');
                query = query + "&mimetype=" + ($scope.SelectedMimeType != undefined ? $scope.SelectedMimeType : '');
                query = query + "&rft=" + (($scope.FilterType != null && $scope.FilterType != undefined) ? $scope.FilterType : '');
                query = query + "&ism=" + ($scope.IsMenuFilter ? '1' : '0');
                query = query + "&idl=" + ($scope.IsDocumentLibrary ? '1' : '0');
                query = query + (($scope.WorkingAreaQueryString != null) ? $scope.WorkingAreaQueryString : '');
                query = query + "&sortby=" + ($scope.sortSelectedItem != undefined ? $scope.sortSelectedItem : '');
                query = query + "&sortdir=" + ($scope.sortDirection != undefined ? $scope.sortDirection : '');
                query = query + "&currentPage=" + pageNr;
                query = query + "&rpp=" + recordPerPage;
                if ($scope.SelectedFileSystemId && $scope.SearchingText)
                    query = query + "&pfId=" + $scope.SelectedFileSystemId;
                return query;
            };
            // Method called to search cms content
            $scope.search = function (pageNr, selfolderId, altercallbackfunc) {
                if (pageNr === void 0) { pageNr = null; }
                if (selfolderId === void 0) { selfolderId = null; }
                if (altercallbackfunc === void 0) { altercallbackfunc = null; }
                if (pageNr == null || pageNr < 1)
                    pageNr = 1;
                controller.Search($scope.searchServiceName, $scope.getSearchQS(pageNr, $scope.RecordPerPage), function (data) {
                    if (altercallbackfunc)
                        altercallbackfunc(data);
                    else {
                        var searchResult = data.Data;
                        if (searchResult != null) {
                            $scope.paging.maxPages = searchResult.maxPages;
                            $scope.paging.currentPage = searchResult.currentPage;
                            $scope.paging.totlaResults = searchResult.totlaResults;
                            $scope.paging.GetSelectablePages();
                            $scope.results = searchResult.resultSet;
                        }
                        else {
                            $scope.paging.currentPage = 1;
                            $scope.paging.maxPages = 0;
                            $scope.paging.totlaResults = 0;
                            $scope.results = null;
                        }
                        $scope.safeApply();
                    }
                });
            };
            // reset all search filters and call a new searh
            $scope.resetSearch = function (resetAlsoSelFolder) {
                if (resetAlsoSelFolder === void 0) { resetAlsoSelFolder = false; }
                $scope.paging.currentPage = 1;
                $scope.SearchingText = "";
                //$scope.SelectedLanguage = null;
                $scope.SelectedMimeType = "";
                $scope.FilterType = '';
                $scope.sortDirection = "";
                $scope.sortSelectedItem = "";
                if (resetAlsoSelFolder) {
                    $scope.SelectedFileSystemId = null;
                    $scope.SelectedFileSystemName = null;
                }
                $scope.search();
            };
            // Default behavior for content click
            $scope.selectFileSystemCallBack = function (lang, fsId, name, filetypeid, mimetype, alternativeUrlId, waUrlId) {
                var link = '/' + lang;
                if (filetypeid == null) {
                    alert("The selected content has not an associated mime type. Contact your system administrator.");
                    return;
                }
                else {
                    if (filetypeid == 1)
                        link = link + $scope.LinkHTMLPageSelected;
                    if (filetypeid == 2)
                        link = link + $scope.LinkBinaryPageSelected;
                    if (filetypeid == 0)
                        return;
                }
                if (fsId != null && fsId != '')
                    link = link + "/" + fsId;
                if ($scope.WorkingAreaQueryString != null && $scope.WorkingAreaQueryString != '')
                    link = link + "?" + $scope.WorkingAreaQueryString;
                if (link.indexOf('?') == -1)
                    link = link + "?";
                else
                    link = link + "&";
                if ($scope.IsDocumentLibrary == true)
                    link = link + "idl=1";
                else
                    link = link + "idl=0";
                location.href = link;
            };
            // method to manage the selection of a working area or a right 
            $scope.selectDeselectRightOrWA = function (isChecked, id, model, objtype) {
                if (model == null || id == null || isChecked == null || objtype == null)
                    return;
                if (model.LinkedRightOrWAList == null)
                    model.LinkedRightOrWAList = new Array();
                model.IsPublicRight = false;
                model.IsAuthenticatedRight = false;
                if (isChecked) {
                    var item = new Module.Abstract.VMBase();
                    item.Id = id;
                    item.Type = objtype;
                    model.LinkedRightOrWAList.push(item);
                }
                else {
                    model.LinkedRightOrWAList = $.grep(model.LinkedRightOrWAList, function (value) {
                        return value.Id != id;
                    }, false);
                }
                return model;
            };
            // get grants and permission from the server (working areas and rights)
            $scope.loadGrants = function () {
                var authQS = $scope.WorkingAreaQueryString + "&area=" + ((!$scope.IsDocumentLibrary) ? "WC" : "DOC_LIB");
                controller.CallGetAction("WorkingArea", "GetMyWorkingAreas", null, function (data) {
                    if (data.Data != null) {
                        if ($scope.WorkingAreaId == null || $scope.WorkingAreaId == '')
                            $scope.PartialWorkingAreas = data.Data;
                        else {
                            $scope.PartialWorkingAreas = [];
                            data.Data.forEach(function (x) {
                                if (x.Id == $scope.WorkingAreaId) {
                                    $scope.PartialWorkingAreas.push(x);
                                }
                            });
                        }
                    }
                    if ($scope.PartialWorkingAreas != undefined && $scope.PartialWorkingAreas != null) {
                        $scope.PartialWorkingAreas.forEach(function (x) { x.isChecked = false; });
                    }
                    $scope.safeApply();
                }, null, authQS);
                if ($scope.PartialRights != null) {
                    $scope.PartialRights.forEach(function (x) { x.Rights.forEach(function (p) { p.isChecked = false; }); });
                }
                $scope.safeApply();
            };
            // lock resource method 
            $scope.lockUploadModel = function (parId, secondParId, refreshTab) {
                if (secondParId === void 0) { secondParId = null; }
                if (refreshTab === void 0) { refreshTab = true; }
                controller.Lock("FileSystem", parId, secondParId, function (data) {
                    $scope.FileModel = data.Data;
                    $scope.loadGrants();
                }, function () {
                    MessagesModule.MessagesController.prototype.ShowMessageBox("Do you want to unlock the resource?", MessagesModule.MessageBoxType.YESNO, "UNLOCK RESOURCE", function () {
                        $scope.forceUploadUnlock($scope.IdFileModel, function () { $scope.lockUploadModel($scope.IdFileModel); });
                    }, function () {
                        $scope.UploadPartialVisibility = true;
                        $scope.UploadFilePermissionVisibility = false;
                    });
                }, true, $scope.WorkingAreaQueryString);
            };
            // unlock resource method
            $scope.unlock = function (id) {
                controller.CallPutAction("FileSystem", "ForceUnlock", id, null, function (data) {
                    $scope.search();
                });
            };
            // force unlock of the filesystem
            $scope.forceUploadUnlock = function (id, callback) {
                controller.CallPutAction("FileSystem", "ForceUnlock", id, null, function (data) {
                    if (callback != null)
                        callback(id);
                }, function () {
                    MessagesModule.MessagesController.prototype.ShowMessageBox("Unlock Error!", MessagesModule.MessageBoxType.ERROR, "Error", null, null, function () {
                        $scope.UploadPartialVisibility = true;
                        $scope.UploadFilePermissionVisibility = false;
                    });
                });
            };
            // confirm the upload after have choose privilegies
            $scope.confirmUploadFile = function () {
                controller.Put("FileSystem", $scope.FileModel.FileSystemId, $scope.FileModel, function (data) {
                    var content = $scope.FileModel;
                    $scope.selectFileSystemCallBack("en", content.FileSystemId, content.MimeType, content.Name, content.AlternativeUrlId, content.WaUrlId);
                });
            };
            // upload/update file callback
            $scope.updateFile = function (newfile) {
                if (newfile.Type == 1 || newfile.Type == 2) {
                    alert(newfile.Message);
                    return;
                }
                if (newfile == null || newfile == undefined || newfile.Type == 1) {
                    $scope.UploadPartialVisibility = true;
                    $scope.UploadFilePermissionVisibility = false;
                    MessagesModule.MessagesController.prototype.ShowMessageBox("Error on uploading file", MessagesModule.MessageBoxType.ERROR, "ERROR", null, null, function () { return; }, function () { return; });
                    return;
                }
                $scope.UploadPartialVisibility = false;
                $scope.UploadFilePermissionVisibility = true;
                $scope.IdFileModel = newfile.Data[0];
                $scope.lockUploadModel($scope.IdFileModel);
            };
            // call the WEB content page without id, to create a new WEB html content
            $scope.newWebContent = function (parentId) {
                var url = '/en' + $scope.LinkHTMLPageSelected + '?';
                if ($scope.BackQueryString != null && $scope.BackQueryString != '')
                    url = url + $scope.BackQueryString;
                if ($scope.WorkingAreaQueryString != null && $scope.WorkingAreaQueryString != '')
                    url = url + $scope.WorkingAreaQueryString;
                if ($scope.IsDocumentLibrary == true)
                    url = url + "&idl=1";
                else
                    url = url + "&idl=0";
                if (parentId != null && parentId != '')
                    url = url + "&pid=" + parentId;
                controller.RedirectToUrl(url);
            };
            // delete a resource
            $scope.deleteResource = function (id) {
                MessagesModule.MessagesController.prototype.ShowMessageBox("Are you sure to delete the resource?", MessagesModule.MessageBoxType.YESNO, "DELETE RESOURCE", function () {
                    controller.Delete("FileSystem", id, function (data) {
                        $scope.search();
                    }, null, $scope.WorkingAreaQueryString);
                });
            };
            // Initialize
            $scope.Init = function () {
                // get mimetypes and then launch the search
                _this.GetCache("MIME_TYPES", function (data) {
                    $scope.MimeTypes = data.Data;
                    //       $scope.search(); // launch first search
                });
                controller.CallGetAction("Role", "GetCMSProfileApplications", null, function (data) { $scope.PartialRights = data.Data; }, null, $scope.WorkingAreaQueryString);
            };
            $scope.Init();
            return _this;
        }
        return ContentSearchResource;
    }(SearchModule.GenericSearchController));
    ContentResourceSearchModule.ContentSearchResource = ContentSearchResource;
})(ContentResourceSearchModule || (ContentResourceSearchModule = {}));
angular.module('minervaApp').controller("ContentResourceSearchModule.ContentSearchResource", ["$scope", "$http", ContentResourceSearchModule.ContentSearchResource]);
//PartialContentSearch.js.map;
/*! ResourceController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var ResourcesModule;
(function (ResourcesModule) {
    var ResourceController = /** @class */ (function (_super) {
        __extends(ResourceController, _super);
        function ResourceController($scope, $http, $timeout, area, servicename) {
            var _this = 
            // call CrudBaseController but do not run the  loadPage method
            _super.call(this, $scope, $http, area, servicename, false) || this;
            var controller = _this;
            $scope.WorkingAreas = [];
            // get isdocument library parameter from query string
            var isDocLib = controller.GetParameterByName('idl');
            if (isDocLib != null && isDocLib != '' && isDocLib != 'undefined' && isDocLib == '1') {
                $scope.bIsDocLib = true;
            }
            else
                $scope.bIsDocLib = false;
            // set the query string to call in case of update, add, lock,unlock and get
            $scope.AddModelQueryString = $scope.UpdateModelQueryString = $scope.LockModelQueryString = $scope.UnlockModelQueryString = $scope.GetModelQueryString = (($scope.bIsDocLib) ? "idl=1" : "idl=0");
            $scope.IsLoading = false;
            $scope.BackMenuQueryString = "";
            $scope.MenuIdBack = controller.GetParameterByName('mId');
            if ($scope.MenuIdBack != null && $scope.MenuIdBack != '')
                $scope.BackMenuQueryString = "&mId=" + $scope.MenuIdBack;
            // AL ADJUSTMENTS: Workign area must be inserted in the url with a new routing. remove it from query string
            // get working area from query string 
            var waId = controller.GetParameterByName('waId');
            $scope.WorkingAreaQueryString = "";
            if (waId != null && waId != '' && waId != 'undefined') {
                $scope.WorkingAreaId = waId;
                $scope.WorkingAreaQueryString = "&waId=" + $scope.WorkingAreaId;
                // add working area parameter to query string to call in case of update, add, lock,unlock and get
                $scope.AddModelQueryString += $scope.WorkingAreaQueryString;
                $scope.UpdateModelQueryString += $scope.WorkingAreaQueryString;
                $scope.LockModelQueryString += $scope.WorkingAreaQueryString;
                $scope.UnlockModelQueryString += $scope.WorkingAreaQueryString;
                $scope.GetModelQueryString += $scope.WorkingAreaQueryString;
                // If a workinga area is specified, the lock is not implicit, so you have not to unlock the resource automatically when exit from the page.
                $scope.doNotUnlockOnExit = true;
            }
            // override of the parent loadPage method
            $scope.loadPage = function () {
                $scope.IsNew = ($scope.urlVars[5] == undefined || $scope.urlVars[5] == null || $scope.urlVars[5] == '');
                $scope.IsEdit = !$scope.IsNew;
                $scope.IsLockedByMe = false;
                $scope.ParentId = controller.GetParameterByName('pid');
                if ($scope.IsEdit) {
                    // if is edit 
                    $scope.IdModel = $scope.urlVars[5];
                    // in case is a working resource, the lock is not implicit, but explicit using a lock button
                    /*if ($scope.WorkingAreaId != null && $scope.WorkingAreaId != '')
                        $scope.getModel($scope.IdModel);
                    else */
                    $scope.lockModel($scope.IdModel); //otherwise lock the resource
                }
                else {
                    // in case of new resource set the parent parameter to create it under a specific parent
                    var parentQueryString = "";
                    if ($scope.ParentId != null && $scope.ParentId != '')
                        parentQueryString = "&pid=" + $scope.ParentId;
                    if ($scope.IsWebContent)
                        $scope.getNewModelInstance("iwc=1" + $scope.WorkingAreaQueryString + parentQueryString); // in case of web content 
                    else
                        $scope.getNewModelInstance("iwc=0" + $scope.WorkingAreaQueryString + parentQueryString); // in case of binary resource
                }
            };
            // New model calback definition
            $scope.getNewModelInstanceCallBack = function () {
                $scope.SelectedContContainerIndex = 0;
                $scope.selectIsApplication();
            };
            // AL ADJUSTMENTS: This method is specific in case of select of IsApplication flag but it is very similar to lockModelCallBack. MERGE THE TWO METHODS?
            // in case IsApplication flag is selected, load rights insted of working areas as privileges and clear the resource selected rights. If the flag is false do the opposite.
            $scope.selectIsApplication = function () {
                var authQS = $scope.WorkingAreaQueryString + "&area=" + (($scope.IsWebContent) ? "WC" : "DOC_LIB");
                controller.CallGetAction("WorkingArea", "GetMyWorkingAreas", null, function (data) {
                    if (data.Data != null) {
                        // if it is a minerva working area resource (not working area specified), get all working areas. 
                        if ($scope.WorkingAreaId == null || $scope.WorkingAreaId == '')
                            $scope.WorkingAreas = data.Data;
                        else // otherwise fill the list only with the select working area
                            data.Data.forEach(function (x) {
                                if (x.Id == $scope.WorkingAreaId) {
                                    $scope.WorkingAreas.push(x);
                                }
                            });
                    }
                    // uncheck all working areas
                    if ($scope.WorkingAreas != undefined && $scope.WorkingAreas != null) {
                        $scope.WorkingAreas.forEach(function (x) { x.isChecked = false; });
                    }
                }, null, authQS);
                // uncheck all working rights
                if ($scope.Rights != null) {
                    $scope.Rights.forEach(function (x) { x.Rights.forEach(function (p) { p.isChecked = false; }); });
                }
                // show the right selection panel if IsApplication
                $scope.ShowProfileSelection = $scope.Model.IsApplication;
                $scope.ShowWASelection = !$scope.Model.IsApplication;
                // reset all grants and permissions for the resource
                $scope.Model.ContentContainerItems.forEach(function (container) {
                    container.IsPublicRight = false;
                    container.IsAuthenticatedRight = false;
                    container.LinkedRightOrWAList = [];
                    container.IsApplication = $scope.Model.IsApplication;
                });
                $scope.IsPublicRightSelected = false;
                $scope.IsAuthRightSelected = false;
                $scope.SelectedAuthRightContentId = null;
                $scope.SelectedPublicRightContentId = null;
                $scope.AssignedRRList = [];
                $scope.safeApply();
            };
            // define the lock callback
            $scope.lockModelCallBack = function () {
                if ($scope.Model == null || $scope.Model.ContentContainerItems == null)
                    return;
                if ($scope.Model.ContentContainerItems.length < 1)
                    return;
                $scope.SelectedContContainerIndex = 0;
                $scope.SelectedMimeType = $scope.Model.MimeType.MimeTypeId;
                $scope.WorkingAreas = [];
                var authQS = $scope.WorkingAreaQueryString + "&area=" + (($scope.IsWebContent) ? "WC" : "DOC_LIB");
                controller.CallGetAction("WorkingArea", "GetMyWorkingAreas", null, function (data) {
                    if (data.Data != null) {
                        // if it is a minerva working area resource (not working area specified), get all working areas. 
                        if ($scope.WorkingAreaId == null || $scope.WorkingAreaId == '')
                            $scope.WorkingAreas = data.Data;
                        else // otherwise fill the list only with the select working area
                            data.Data.forEach(function (x) {
                                if (x.Id == $scope.WorkingAreaId) {
                                    $scope.WorkingAreas.push(x);
                                }
                            });
                        // unckec all working areas
                        if ($scope.WorkingAreas != null) {
                            $scope.WorkingAreas.forEach(function (x) { x.isChecked = false; });
                        }
                        // unckec all rights
                        if ($scope.Rights != null) {
                            $scope.Rights.forEach(function (x) { x.Rights.forEach(function (right) { right.isChecked = false; }); });
                        }
                        // if it is a Web content the assignment of the rights are split by the content container.
                        // if a right or a working area is selected, another container cannot select it anymore. 
                        // if Public right or Every auth right is selected, the user cannot assign any other right to the container
                        if ($scope.IsWebContent) {
                            $scope.AssignedRRList = new Array();
                            // loop all containers
                            $scope.Model.ContentContainerItems.forEach(function (container) {
                                if (container.IsPublicRight) {
                                    $scope.IsPublicRightSelected = true;
                                    $scope.SelectedPublicRightContentId = container.ContentId;
                                }
                                else {
                                    if (container.IsAuthenticatedRight) {
                                        $scope.IsAuthRightSelected = true;
                                        $scope.SelectedAuthRightContentId = container.ContentId;
                                    }
                                    else {
                                        if ($scope.Model.IsApplication) {
                                            if ($scope.Rights != null) {
                                                $scope.Rights.forEach(function (appright) {
                                                    appright.Rights.forEach(function (right) {
                                                        container.LinkedRightOrWAList.forEach(function (rightOrWA) {
                                                            if (rightOrWA.Id == right.RightId) {
                                                                right.isChecked = true;
                                                                $scope.AssignedRRList.push(right.RightId + container.ContentId);
                                                            }
                                                        });
                                                    });
                                                });
                                            }
                                        }
                                        else {
                                            $scope.WorkingAreas.forEach(function (wa) {
                                                container.LinkedRightOrWAList.forEach(function (rightOrWA) {
                                                    if (rightOrWA.Id == wa.Id) {
                                                        wa.isChecked = true;
                                                        $scope.AssignedRRList.push(wa.Id + container.ContentId);
                                                    }
                                                });
                                            });
                                        }
                                    }
                                }
                            });
                        }
                        else {
                            // if it is a binary file loop all working areas and rights and select which are conteined inside the LinkedRightOrWAList list
                            if ($scope.WorkingAreas != null) {
                                $scope.WorkingAreas.forEach(function (wa) {
                                    $scope.Model.ContentContainerItems.forEach(function (container) {
                                        container.LinkedRightOrWAList.forEach(function (rightOrWA) {
                                            if (wa.Id == rightOrWA.Id) {
                                                wa.isChecked = true;
                                            }
                                        });
                                    });
                                });
                            }
                            if ($scope.Rights != null) {
                                $scope.Rights.forEach(function (x) { x.Rights.forEach(function (right) { $scope.Model.ContentContainerItems.forEach(function (container) { container.LinkedRightOrWAList.forEach(function (rightOrWA) { if (right.RightId == rightOrWA.Id) {
                                    right.isChecked = true;
                                } }); }); }); });
                            }
                        }
                    }
                }, null, authQS);
                // show the right selection panel if IsApplication
                $scope.ShowProfileSelection = $scope.Model.IsApplication;
                $scope.ShowWASelection = !$scope.Model.IsApplication;
            };
            // force unlock
            $scope.forceUnlock = function (id, callback) {
                controller.CallPutAction($scope.serviceName, "ForceUnlock", id, null, function (data) {
                    if (callback != null)
                        callback(id);
                }, function () {
                    MessagesModule.MessagesController.prototype.ShowMessageBox("Unlock Error!", MessagesModule.MessageBoxType.ERROR, "Error", null, null, function () { window.history.back(); });
                });
            };
            // in case the lock return an error
            $scope.lockModelErrorCallBack = function () {
                if ($scope.WorkingAreaId != null && $scope.WorkingAreaId != '') {
                    window.history.back();
                    return;
                }
                MessagesModule.MessagesController.prototype.ShowMessageBox("Do you want to unlock the resource?", MessagesModule.MessageBoxType.YESNO, "UNLOCK RESOURCE", function () {
                    $scope.forceUnlock($scope.IdModel, function () { $scope.loadPage(); });
                }, function () { window.history.back(); });
            };
            // get model callback
            $scope.getModelCallBack = function () {
                controller.CallGetAction($scope.serviceName, "IsLocked", $scope.Model.FileSystemId, function (data) {
                    if (data.Data != null && data.Data.length == 3) {
                        $scope.IsLockedByMe = data.Data[0];
                        $scope.IsLockedBySomeone = data.Data[1];
                        $scope.LockUser = data.Data[2];
                        $scope.lockModelCallBack();
                    }
                    else
                        window.history.back();
                }, null, $scope.WorkingAreaQueryString);
            };
            // add model callback
            $scope.addModelCallBack = function (model) {
                // if the resource is created from a menu, save the new resource as a target of the menu 
                if ($scope.MenuIdBack != null && $scope.MenuIdBack != '') {
                    controller.CallPutAction("Menu", "SaveMenuTargetId", $scope.MenuIdBack, null, function (data) {
                        if ($scope.IsWebContent)
                            $scope.redirectToAction($scope.Language, "Admin", "cms", "webpageedit", model.FileSystemId, (($scope.IsDocLibBack) ? "idl=0" : "") + $scope.BackMenuQueryString + $scope.WorkingAreaQueryString);
                        else
                            $scope.redirectToAction($scope.Language, "Admin", "resources", "resourceedit", model.FileSystemId, $scope.BackMenuQueryString + $scope.WorkingAreaQueryString);
                    }, null, "tId=" + model.FileSystemId + $scope.WorkingAreaQueryString);
                }
                else {
                    // in case of web content redirect to web content edit page. in case of binary, redirect to binary edit page
                    if ($scope.IsWebContent)
                        $scope.redirectToAction($scope.Language, "Admin", "cms", "webpageedit", model.FileSystemId, (($scope.IsDocLibBack) ? "idl=0" : "") + $scope.WorkingAreaQueryString);
                    else
                        $scope.redirectToAction($scope.Language, "Admin", "resources", "resourceedit", model.FileSystemId, $scope.WorkingAreaQueryString);
                }
            };
            // the base controller call this method before save
            $scope.checkMandatoryFields = function (successCallBack) {
                if (successCallBack != null)
                    successCallBack();
            };
            // delete model
            $scope.deleteModel = function () {
                if ($scope.IsEdit && $scope.Model.FileSystemId != null && $scope.Model.FileSystemId != "") {
                    MessagesModule.MessagesController.prototype.ShowMessageBox("Are you sure to permanently delete all the entire content?", MessagesModule.MessageBoxType.YESNO, "DELETE RESOURCE", function () {
                        $scope.Model.ContentContainerItems = new Array();
                        controller.Delete($scope.serviceName, $scope.Model.FileSystemId, function (data) {
                            $scope.Model = null;
                            // redirect tot the resource browse page 
                            if ($scope.IsWebContent || !$scope.bIsDocLib)
                                return controller.RedirectToAction($scope.Language, "Admin", "cms", "resources", null, $scope.WorkingAreaQueryString);
                            else
                                return controller.RedirectToAction($scope.Language, "Admin", "resources", "resources", null, $scope.WorkingAreaQueryString);
                        }, null, $scope.WorkingAreaQueryString);
                    });
                }
            };
            // delete content container
            $scope.deleteContentContainer = function () {
                if ($scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex] == null) {
                    alert("Container tab does not exist.");
                    return;
                }
                $scope.mainForm.$dirty = true;
                $scope.mainForm.$pristine = false;
                // if the container is not already saved in the db, remove it from the list on client side
                if ($scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].ContentId == null) {
                    $scope.Model.ContentContainerItems.splice($scope.SelectedContContainerIndex, 1);
                    $scope.SelectedContContainerIndex = $scope.SelectedContContainerIndex - 1;
                    return;
                }
                MessagesModule.MessagesController.prototype.ShowMessageBox("Are you sure to delete the container tab and its content items?", MessagesModule.MessageBoxType.YESNO, "DELETE CONTENT CONTAINER", function () {
                    controller.CallPutAction($scope.serviceName, "DeleteContentContainer", $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].ContentId, null, function (data) {
                        location.href = location.href;
                    }, null, $scope.WorkingAreaQueryString);
                });
            };
            // delete all content inside the container
            $scope.deleteContentContainerItems = function () {
                if ($scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex] == null) {
                    alert("Container tab does not exist.");
                    return;
                }
                if ($scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].ContentId == null) {
                    alert("Container tab is new and does not contain items.");
                    return;
                }
                MessagesModule.MessagesController.prototype.ShowMessageBox("Are you sure to delete all container content items?", MessagesModule.MessageBoxType.YESNO, "DELETE CONTENT CONTAINER", function () {
                    controller.CallPutAction($scope.serviceName, "DeleteContentContainerItems", $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].ContentId, null, function (data) {
                        $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].ContentItems.forEach(function (s) {
                            s.StatusId = "CMS_DELETED";
                        });
                    }, null, $scope.WorkingAreaQueryString);
                });
            };
            // delete a specific content
            $scope.deleteContent = function (contentVersionId) {
                MessagesModule.MessagesController.prototype.ShowMessageBox("Are you sure to delete the content item?", MessagesModule.MessageBoxType.YESNO, "DELETE CONTENT", function () {
                    controller.Delete("ContentData", contentVersionId, function (data) {
                        $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].ContentItems.forEach(function (s) {
                            if (s.VersionId == contentVersionId)
                                s.StatusId = "CMS_DELETED";
                        });
                    }, null, $scope.WorkingAreaQueryString);
                });
            };
            // after save callback
            $scope.afterSaveCallBack = function (model) {
                $scope.mainForm.$dirty = false;
                $scope.mainForm.$pristine = true;
                if ($scope.MenuIdBack != null && $scope.MenuIdBack != '') {
                    controller.CallPutAction("Menu", "SaveMenuTargetId", $scope.MenuIdBack, null, function (data) {
                    }, null, "tId=" + model.FileSystemId + $scope.WorkingAreaQueryString);
                }
            };
            //$scope.getLinkedFileSystems = function ()
            //{
            //    controller.CallGetAction("FileSystem", "GetFileSystemLinkedContentList", $scope.MenuIdBack, null, function (data: Module.VMResult) {
            //        data.Data;
            //    }, null, $scope.WorkingAreaQueryString);
            //    LinkedFileSystem
            //}
            $scope.CopyUrlToClipboard = function (text) {
                //var Copied = text.createTextRange();
                //Copied.execCommand("Copy");
                var tempInput = document.createElement("input");
                tempInput.style.cssText = "position: absolute; left: -1000px; top: -1000px";
                tempInput.value = text;
                document.body.appendChild(tempInput);
                tempInput.select();
                document.execCommand("copy");
                document.body.removeChild(tempInput);
            };
            // function to manage exit mode button click event
            $scope.exitEditMode = function (area, controllerName, action, id, queryString, unlock) {
                if (action === void 0) { action = null; }
                if (id === void 0) { id = null; }
                if (queryString === void 0) { queryString = null; }
                if (unlock === void 0) { unlock = true; }
                var url = controller.CreateUrl($scope.Language, area, controllerName, action, id, queryString);
                if ($scope.mainForm.$pristine) {
                    if (id == null)
                        id = $scope.IdModel;
                    // if is locked by the current user
                    if ((!$scope.IsNew || $scope.IsLockedByMe) && id != null && id != '' && unlock)
                        $scope.unlockModel(id, function () {
                            controller.RedirectToUrl(url);
                            return;
                        });
                    else
                        controller.RedirectToUrl(url);
                    return;
                }
                MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("MINERVA_EXITEDIT_QUESTION"), MessagesModule.MessageBoxType.YESNO, "", function () {
                    if (id == null)
                        id = $scope.IdModel;
                    // if is locked by the current user
                    if ((!$scope.IsNew || $scope.IsLockedByMe) && id != null && id != '' && unlock)
                        $scope.unlockModel(id, function () {
                            controller.RedirectToUrl(url);
                        });
                    else
                        controller.RedirectToUrl(url);
                });
            };
            // redirect to new web content page in case the current is a web content resource. otherwise redirect to new binary page
            $scope.addNewResource = function (area, controllerName, action, id, queryString) {
                if (action === void 0) { action = null; }
                if (id === void 0) { id = null; }
                if (queryString === void 0) { queryString = null; }
                MessagesModule.MessagesController.prototype.ShowMessageBox("Do you want to create a new content?", MessagesModule.MessageBoxType.YESNO, "", function () {
                    var parentQueryString = "";
                    if ($scope.ParentId != null && $scope.ParentId != '')
                        parentQueryString = "&pid=" + $scope.ParentId;
                    if ($scope.IsWebContent || !$scope.bIsDocLib)
                        $scope.redirectToAction($scope.Language, "admin", "cms", "webpageedit", null, $scope.BackMenuQueryString + $scope.WorkingAreaQueryString + parentQueryString);
                    else
                        $scope.redirectToAction($scope.Language, "admin", "resources", "resourceedit", null, $scope.BackMenuQueryString + $scope.WorkingAreaQueryString + parentQueryString);
                });
            };
            // to update only the alternative url information
            $scope.updateAlternativeUrl = function () {
                if ($scope.Model == null || $scope.IsNew || !$scope.IsLockedByMe)
                    return;
                MessagesModule.MessagesController.prototype.ShowMessageBox("Are you sure to update the alternative URL?", MessagesModule.MessageBoxType.YESNO, "", function () {
                    controller.CallPutAction($scope.serviceName, "UpdateAlternativeUrl", $scope.Model.FileSystemId, $scope.Model, function (data) {
                        MessagesModule.MessagesController.prototype.ShowMessageBox("Success!", MessagesModule.MessageBoxType.SUCCESS, "Alternative Url successfully updated!");
                        $scope.Model.AlternativeUrlId = data.Data;
                        $scope.safeApply();
                    });
                });
            };
            // Load cache data
            _this.GetCache("MENU_THEMES", function (data) { $scope.Themes = data.Data; });
            _this.GetCache("TRANSLATEDLANGUAGES", function (data) {
                $scope.Languages = data.Data;
                controller.CallGetAction("Role", "GetCMSProfileApplications", null, function (data) {
                    $scope.Rights = data.Data;
                    $scope.loadPage();
                }, null, $scope.WorkingAreaQueryString);
            });
            return _this;
        }
        return ResourceController;
    }(BaseModule.CrudBaseController));
    ResourcesModule.ResourceController = ResourceController;
    // THIS CLASS IS SPECIFIC FOR WEB CONTENT RESOURCE, AND EXTENDS THE BASE ResourceController 
    var WebPageResourceController = /** @class */ (function (_super) {
        __extends(WebPageResourceController, _super);
        function WebPageResourceController($scope, $http, $timeout) {
            var _this = this;
            $scope.IsWebContent = true;
            _this = _super.call(this, $scope, $http, $timeout, "Admin", "FileSystem") || this;
            var controller = _this;
            $scope.Preview = function (workingAreaName, contentItemId, language) {
                return controller.RedirectToAction(language, "preview", workingAreaName, $scope.Model.FileSystemId, contentItemId);
            };
            // change tab 
            $scope.changeTab = function (tabId) {
                $scope.SelectedContContainerIndex = tabId;
                $scope.safeApply();
            };
            // when public right is selected, it is not possible to set it in another container, and it is not possible to select other right for the same container
            // This method is called by the WebPageEdit.cshtml
            $scope.selectPublicRight = function () {
                var i = 0;
                var ispresent = false;
                for (i = 0; i < $scope.Model.ContentContainerItems.length; i++) {
                    if ($scope.IsPublicRightSelected) {
                        $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].LinkedRightOrWAList = new Array();
                        $scope.SelectedPublicRightContentId = $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].ContentId;
                        $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].IsPublicRight = true;
                        $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].IsAuthenticatedRight = false;
                    }
                    else {
                        $scope.Model.ContentContainerItems[i].IsPublicRight = false;
                    }
                }
                if (!$scope.IsPublicRightSelected)
                    $scope.SelectedPublicRightContentId = null;
            };
            // when authentication right is selected, it is not possible to set it in another container, and it is not possible to select other right for the same container
            // This method is called by the WebPageEdit.cshtml
            $scope.selectAuthRight = function () {
                var i = 0;
                var ispresent = false;
                for (i = 0; i < $scope.Model.ContentContainerItems.length; i++) {
                    if ($scope.IsAuthRightSelected) {
                        $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].LinkedRightOrWAList = new Array();
                        $scope.SelectedAuthRightContentId = $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].ContentId;
                        $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].IsAuthenticatedRight = true;
                        $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].IsPublicRight = false;
                    }
                    else {
                        $scope.Model.ContentContainerItems[i].IsAuthenticatedRight = false;
                    }
                }
                if (!$scope.IsAuthRightSelected)
                    $scope.SelectedAuthRightContentId = null;
            };
            // when a right or a working area is selected, this method add it to the right container. doing so it is not possible to select it in another container 
            // This method is called by the WebPageEdit.cshtml
            $scope.selectDeselectRightOrWA = function (rightOrWAId, rightOrWAComposedId, objtype) {
                if ($scope.AssignedRRList == null)
                    $scope.AssignedRRList = new Array();
                if ($scope.isRRAlreadyAssignedByAnother(rightOrWAId)) {
                    alert("Error. RR already assigned to another container.");
                    return;
                }
                var i = 0;
                var ispresent = false;
                for (i = 0; i < $scope.AssignedRRList.length; i++) {
                    if ($scope.AssignedRRList[i] == rightOrWAComposedId) {
                        ispresent = true;
                        break;
                    }
                }
                if (!ispresent || $scope.AssignedRRList.length == 0) {
                    var item = new Module.Abstract.VMBase();
                    item.Id = rightOrWAId;
                    item.Type = objtype;
                    $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].LinkedRightOrWAList.push(item);
                    $scope.AssignedRRList.push(rightOrWAComposedId);
                }
                else {
                    for (i = 0; i < $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].LinkedRightOrWAList.length; i++) {
                        if ($scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].LinkedRightOrWAList[i].Id + $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].ContentId == rightOrWAComposedId) {
                            $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].LinkedRightOrWAList.splice(i, 1);
                            break;
                        }
                    }
                    for (i = 0; i < $scope.AssignedRRList.length; i++) {
                        if ($scope.AssignedRRList[i] == rightOrWAComposedId) {
                            $scope.AssignedRRList.splice(i, 1);
                            break;
                        }
                    }
                }
                for (i = 0; i < $scope.Model.ContentContainerItems.length; i++) {
                    if ($scope.Model.ContentContainerItems[i].ContentId == $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].ContentId) {
                        $scope.Model.ContentContainerItems[i] = $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex];
                        break;
                    }
                }
            };
            // chekc if the right or working area is already assigned in another container
            // This method is called by the WebPageEdit.cshtml
            $scope.isRRAlreadyAssignedByAnother = function (rightOrWAId) {
                if ($scope.AssignedRRList == null || $scope.Model == null || $scope.Model.ContentContainerItems == null ||
                    ($scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex] != null && $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].ContentId != null))
                    return false;
                var selContId = "";
                if ($scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex] != null)
                    selContId = $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].ContentId;
                var i = 0;
                var j = 0;
                var foud = false;
                for (i = 0; i < $scope.AssignedRRList.length; i++) {
                    for (j = 0; j < $scope.Model.ContentContainerItems.length; j++) {
                        if ($scope.Model.ContentContainerItems[j].ContentId != selContId) {
                            if (rightOrWAId + $scope.Model.ContentContainerItems[j].ContentId == $scope.AssignedRRList[i]) {
                                foud = true;
                                break;
                            }
                        }
                    }
                    if (foud)
                        return true;
                }
                return false;
            };
            // calculate the avaiable languages for the container by filling the combo with the languages which are not already associated to an html content
            // This method is called by the WebPageEdit.cshtml
            $scope.calculateAvailableLanguages = function () {
                if ($scope.Languages == null)
                    return;
                // if model or container are null, return all languages
                if ($scope.Model == null || $scope.Model.ContentContainerItems == null || $scope.SelectedContContainerIndex == null || $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex] == null)
                    return $scope.Languages;
                // calculate langauges
                var langArray = new Array();
                var i = 0;
                var j = 0;
                for (i = 0; i < $scope.Languages.length; i++) {
                    var ispresent = false;
                    for (j = 0; j < $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].ContentItems.length; j++) {
                        if ($scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].ContentItems[j].Language != null
                            && $scope.Languages[i].LanguageId == $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].ContentItems[j].Language.LanguageId) {
                            ispresent = true;
                            break;
                        }
                    }
                    if (!ispresent) {
                        langArray.push($scope.Languages[i]);
                    }
                }
                return langArray;
            };
            // delete all the web contents of the container or the files
            $scope.deleteAll = function () {
                var msg = "Do you want to delete all ";
                if ($scope.IsWebContent)
                    msg = msg + "web contents of this tab?";
                else
                    msg = msg + "files?";
                MessagesModule.MessagesController.prototype.ShowMessageBox(msg, MessagesModule.MessageBoxType.YESNO, "DELETE ALL", function () {
                    $scope.Model.ContentContainerItems = new Array();
                    //$scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex] = new Module.VMContentContainer();
                });
            };
            // add a new content container to the page
            $scope.addContentContainer = function () {
                var j = 0;
                for (j = 0; j < $scope.Model.ContentContainerItems.length; j++) {
                    if ($scope.Model.ContentContainerItems[j].ContentId == null || $scope.Model.ContentContainerItems[j].ContentId == "") {
                        alert("There is already a new empty tab. To add new one please click on save button.");
                        return;
                    }
                }
                var isWc = "0";
                if ($scope.IsWebContent)
                    isWc = "1";
                var isApplication = "0";
                if ($scope.Model.IsApplication)
                    isApplication = "1";
                $scope.mainForm.$dirty = true;
                $scope.mainForm.$pristine = false;
                controller.CallGetAction($scope.serviceName, "NewContentContainerInstance", null, function (data) {
                    $scope.Model.ContentContainerItems.push(data.Data);
                    $scope.SelectedContContainerIndex = $scope.Model.ContentContainerItems.length - 1;
                }, null, "iwc=" + isWc + "&iapp=" + isApplication + $scope.WorkingAreaQueryString);
            };
            // chekc if the template is selectable or not. Each container can have only one template. When the first content language is created, all the other content languages must have the same template
            $scope.isTemplateSelectable = function () {
                if ($scope.Model == null)
                    return true;
                if ($scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex] == null)
                    return true;
                if ($scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].ContentItems == null || $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].ContentItems.length < 1)
                    return true;
                var hasContent = false;
                $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].ContentItems.forEach(function (s) {
                    if (s.HasContent) {
                        hasContent = true;
                    }
                });
                if (!hasContent)
                    return true;
                return false;
            };
            // To create a new language html for the container, redirect to a new htmnl content language page. 
            $scope.addLanguage = function () {
                return controller.RedirectToAction($scope.Language, "Admin", "Cms", "WebContentEdit", null, "?fId=" + $scope.Model.FileSystemId + "&wpId=" + $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].ContentId + "&lId=" + $scope.LanguageToAdd + "&cfwp=1" + $scope.BackMenuQueryString);
            };
            // publish and unpublish events
            $scope.publishUnpublishWebContent = function (model, publish) {
                if (publish && model.IsPublished) {
                    MessagesModule.MessagesController.prototype.ShowMessageBox("Web content is already published", MessagesModule.MessageBoxType.ERROR, "Publishing error", null, null, function () { location.href = location.href; });
                    return;
                }
                controller.CallPutAction("ContentData", "PublishUnpublish", model.VersionId, null, function (data) {
                    model.StatusId = data.Data;
                    model.IsPublished = !model.IsPublished;
                    $scope.wasChanged = false;
                    $scope.shouldBeSaved = false;
                    $scope.forceExit = false;
                }, null, $scope.WorkingAreaQueryString);
            };
            // when the template is selected, change the template id of associated to the container
            $scope.changeTemplate = function (templateId) {
                $scope.mainForm.$dirty = true;
                $scope.mainForm.$pristine = false;
                $scope.Model.ContentContainerItems[$scope.SelectedContContainerIndex].LayoutTemplateId = templateId;
            };
            // AL ADJUSTMENTS: IS IT DEPRECATED?
            // show the linked resources associated to all the html content of the page
            $scope.showLinkedResources = function (fsId) {
                controller.CallGetAction("FileSystem", "GetFileSystemLinkedContentList", fsId, function (data) {
                    if (data.Data == null || data.Data.length == 0)
                        alert("No match was found!");
                    else
                        $scope.LinkedResources = data.Data;
                }, null);
            };
            return _this;
        }
        return WebPageResourceController;
    }(ResourcesModule.ResourceController));
    ResourcesModule.WebPageResourceController = WebPageResourceController;
    // THIS CLASS IS SPECIFIC FOR BINARY RESOURCE, AND EXTENDS THE BASE ResourceController 
    var BinaryResourceController = /** @class */ (function (_super) {
        __extends(BinaryResourceController, _super);
        function BinaryResourceController($scope, $http, $timeout) {
            var _this = this;
            $scope.IsMenuBack = function () {
                return ($scope.MenuIdBack != null && $scope.MenuIdBack != '') ? true : false;
            };
            $scope.IsWebContentBack = function () {
                return (!$scope.IsMenuBack() && $scope.bIsDocLib) ? true : false;
            };
            $scope.IsDocLibBack = function () {
                return (!$scope.IsMenuBack() && !$scope.bIsDocLib) ? true : false;
            };
            // upload/update file callback. this is the callback after an upload is finished
            $scope.updateFile = function (newfile) {
                if (newfile.Type == 1) {
                    alert(newfile.Message);
                    return;
                }
                $scope.Model.MimeType = newfile.Data[2];
                $scope.SelectedMimeType = newfile.Data[2];
                $scope.Model.ContentContainerItems[0].ContentItems.forEach(function (s) {
                    if (s.Language.LanguageId == newfile.Data[0]) {
                        if ($scope.IsNew) {
                            s.Name = newfile.Data[3];
                            $scope.Model.Name = newfile.Data[3];
                            s.MimeType = newfile.Data[2];
                            s.HasContent = true;
                        }
                        else {
                            MessagesModule.MessagesController.prototype.ShowMessageBox("Do you want to replace the current file with the new one?", MessagesModule.MessageBoxType.YESNO, "REPLACE FILE", function () {
                                s.Name = newfile.Data[3];
                                $scope.Model.Name = newfile.Data[3];
                                s.MimeType = newfile.Data[2];
                                s.HasContent = true;
                                $scope.mainForm.$dirty = true;
                                $scope.mainForm.$pristine = false;
                                $scope.safeApply();
                            });
                            $scope.safeApply();
                        }
                    }
                });
            };
            // when a right or a working area is selected, it is not possible to select it in another container
            // This method is called by the _GrantsAuthorisationPartial.cshtml
            $scope.selectDeselectRightOrWA = function (isChecked, id, model, objtype) {
                if (model == null || id == null || isChecked == null || objtype == null)
                    return;
                if (model.LinkedRightOrWAList == null)
                    model.LinkedRightOrWAList = new Array();
                model.IsPublicRight = false;
                model.IsAuthenticatedRight = false;
                if (isChecked) {
                    var item = new Module.Abstract.VMBase();
                    item.Id = id;
                    item.Type = objtype;
                    model.LinkedRightOrWAList.push(item);
                }
                else {
                    model.LinkedRightOrWAList = $.grep(model.LinkedRightOrWAList, function (value) {
                        return value.Id != id;
                    }, false);
                }
                return model;
            };
            $scope.IsWebContent = false;
            _this = _super.call(this, $scope, $http, $timeout, "Admin", "FileSystem") || this;
            var controller = _this;
            return _this;
        }
        return BinaryResourceController;
    }(ResourcesModule.ResourceController));
    ResourcesModule.BinaryResourceController = BinaryResourceController;
})(ResourcesModule || (ResourcesModule = {}));
angular.module('minervaApp').controller("ResourcesModule.ResourceController", ["$scope", "$http", "$timeout", ResourcesModule.ResourceController]);
angular.module('minervaApp').controller("ResourcesModule.WebPageResourceController", ["$scope", "$http", "$timeout", ResourcesModule.WebPageResourceController]);
angular.module('minervaApp').controller("ResourcesModule.BinaryResourceController", ["$scope", "$http", "$timeout", ResourcesModule.BinaryResourceController]);
//ResourceController.js.map;
/*! ResourcesController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var ResourcesModule;
(function (ResourcesModule) {
    // This controller manage the filesystem browse page _ResourceBrowsePartial.cshtml
    var ResourcesController = /** @class */ (function (_super) {
        __extends(ResourcesController, _super);
        function ResourcesController($scope, $http, $timeout) {
            var _this = this;
            var DEFAULTTOTAL = 50;
            $scope.totalDisplayed = DEFAULTTOTAL;
            _this = _super.call(this, $scope, $http) || this;
            var controller = _this;
            $scope.IsFirstLoad = true;
            $scope.showOverlay = false;
            $scope.renameEnabled = false;
            $scope.browseServiceName = "FileSystem";
            $scope.UploadPartialVisibility = true;
            $scope.showrenamebox = false;
            $scope.DownloadVisibility = true;
            $scope.DeleteVisibility = true;
            $scope.FolderVisibility = true;
            // if in the url there is CMS controller, it is not a document library search
            if ($scope.urlVars[3] != undefined && $scope.urlVars[3] != null && $scope.urlVars[3].toLowerCase() == 'cms')
                $scope.IsDocumentLibrary = false;
            else
                $scope.IsDocumentLibrary = true;
            $scope.MimeOption = ContentResourceSearchModule.MimeOptions.All;
            if ($scope.IsDocumentLibrary) {
                $scope.MimeOptionsVisibility = true;
                $scope.ContentTypeVisibility = false;
                $scope.NewWebContentVisibility = false;
            }
            else {
                $scope.MimeOptionsVisibility = true;
                $scope.ContentTypeVisibility = true;
                $scope.NewWebContentVisibility = true;
            }
            // if a filesystem is specified
            if ($scope.urlVars[5] != undefined && $scope.urlVars[5] != null && $scope.urlVars[5] != '')
                $scope.SelectedFileSystemId = $scope.urlVars[5];
            var tinyMCEreference = undefined;
            try {
                tinyMCEreference = eval("winbrowser");
            }
            catch (ex) {
                //do nothing
            }
            finally {
            }
            if (tinyMCEreference != undefined)
                var typeParam = eval("winbrowser.params.type");
            if (typeParam) {
                $scope.UploadPartialVisibility = false;
                $scope.UploadFilePermissionVisibility = false;
                $scope.FolderVisibility = true;
                // depending on the type, initialize properties
                if (typeParam == "file") {
                    $scope.MimeOption = ContentResourceSearchModule.MimeOptions.All;
                    $scope.MimeOptionsVisibility = false;
                    $scope.ContentTypeVisibility = true;
                    $scope.NewWebContentVisibility = false;
                    $scope.DownloadVisibility = false;
                }
                else {
                    $scope.MimeOption = ContentResourceSearchModule.MimeOptions.Image;
                    $scope.MimeOptionsVisibility = false;
                    $scope.ContentTypeVisibility = false;
                    $scope.NewWebContentVisibility = false;
                    $scope.DownloadVisibility = false;
                    $scope.UploadPartialVisibility = true;
                }
                $scope.DeleteVisibility = false;
            }
            $scope.loadMore = function () {
                $scope.totalDisplayed = $scope.totalDisplayed + DEFAULTTOTAL;
            };
            // get the folder tree for the current  working area and if it is a web content or a document library page
            $scope.getFolderTree = function (id, callback) {
                // get menu id from url
                var queryString = '';
                if (id != null && id != '')
                    queryString = "fsId=" + id;
                // AL ADJUSTMENTS: Put working area id inside the url with a new routing, instead of the query string 
                // get working area id
                $scope.WorkingAreaQueryString = '';
                var waId = controller.GetParameterByName('waId');
                if (waId != null && waId != '' && waId != 'undefined') {
                    $scope.WorkingAreaId = waId;
                    $scope.WorkingAreaQueryString = "&waId=" + waId;
                    if (queryString == '')
                        queryString = "waId=" + $scope.WorkingAreaId;
                    else
                        queryString = queryString + "&waId=" + $scope.WorkingAreaId;
                }
                // if is document library add the related value to query string for the get tree call
                if ($scope.IsDocumentLibrary)
                    queryString = queryString + "&idl=1";
                else
                    queryString = queryString + "&idl=0";
                $scope.IsLoading = true;
                controller.CallGetAction($scope.browseServiceName, "GetTree", null, function (data) {
                    $scope.ResourcesRootModel = data.Data;
                    $scope.visit($scope.ResourcesRootModel, function (item) {
                        if (item.icon == null)
                            item.icon = "/Content/themes/admin/images/icons/folder_icon_24.png";
                        if (item.ParentId != null) {
                            item.expanded = false;
                        }
                        else {
                            item.expanded = true;
                        }
                    });
                    // if a filesystem is specified, open the folder
                    if ($scope.SelectedFileSystemId == null || $scope.SelectedFileSystemId == '')
                        $scope.SelectedFileSystemId = data.Data.children[0].Id;
                    if ($scope.SelectedFileSystemId != '')
                        $scope.openFolder($scope.SelectedFileSystemId);
                    $scope.IsLoading = false;
                    $scope.IsFirstLoad = false;
                    $scope.mainForm.$pristine = true;
                    $scope.mainForm.$dirty = false;
                    if (callback != null)
                        callback(id);
                }, function () { $scope.IsLoading = false; }, queryString);
            };
            // this is the method to manage the right click event on all the right part of the page.
            $scope.containerleftclickevent = function () {
                if ($scope.showrenamebox) {
                    for (var i = 0; i < $scope.SelectedFolderChildren.length; i++) {
                        if ($scope.SelectedFolderChildren[i].FileSystemId == $scope.actionMenuFSId) {
                            $scope.Rename($scope.SelectedFolderChildren[i].FileSystemId, $scope.SelectedFolderChildren[i].Name);
                            break;
                        }
                    }
                    $scope.actionMenuFSId = null;
                    $scope.showrenamebox = false;
                    $scope.resetActionMenu();
                }
            };
            // the event associated to the click on the folder on the right side of the page
            $scope.openFolderEvent = function (id) {
                $scope.SelectedFileSystemId = id;
                $scope.openFolder(id);
            };
            $scope.sortBrowse = function (sortKey, sortDir) {
                console.log("sortBrowse");
                if (sortKey != null && sortKey != '')
                    $scope.sortSelectedItem = sortKey;
                if (sortDir != null && sortDir != '')
                    $scope.sortDirection = sortDir;
                $scope.safeApply();
                $scope.openFolder($scope.actualId);
            };
            //Decoupling merge with rev. 4300
            $scope.sortBrowse = function (sortKey, sortDir) {
                console.log("sortBrowse");
                if (sortKey != null && sortKey != '')
                    $scope.sortSelectedItem = sortKey;
                if (sortDir != null && sortDir != '')
                    $scope.sortDirection = sortDir;
                $scope.safeApply();
                $scope.openFolder($scope.actualId);
            };
            //END Decoupling merge with rev. 4300
            // 
            $scope.openFolder = function (id, renameFolderEnabled) {
                if (renameFolderEnabled === void 0) { renameFolderEnabled = false; }
                if (id != null) {
                    if (renameFolderEnabled) {
                        $scope.actionMenuFSId = id;
                    }
                    $scope.totalDisplayed = DEFAULTTOTAL;
                    $scope.actualId = id;
                    $scope.closeActionMenu();
                    $scope.IsLoading = true;
                    $scope.UploadPartialVisibility = true;
                    $scope.UploadFilePermissionVisibility = false;
                    var querystring = $scope.getSearchQS(1, 500);
                    querystring = querystring + "&sortby=" + $scope.sortSelectedItem;
                    querystring = querystring + "&sortdir=" + $scope.sortDirection;
                    controller.CallGetAction($scope.browseServiceName, "GetFolderChildren", id, function (data) {
                        $scope.SelectedFolderChildren = data.Data[1];
                        $scope.SelectedFileSystemName = data.Data[0].Name;
                        $scope.renameEnabled = renameFolderEnabled;
                        var tree = $("#resource_tree").data("ui-fancytree").getTree();
                        tree.activateKey(id);
                        $scope.mainForm.$pristine = true;
                        $scope.mainForm.$dirty = false;
                        $scope.showOverlay = false;
                        $scope.safeApply();
                    }, function () {
                        $scope.IsLoading = false;
                        if (renameFolderEnabled) {
                            $("#renameTextBox").focus();
                        }
                    }, querystring);
                }
            };
            $scope.removeItem = function (id) {
                var x = confirm(controller.GetMessage("CMS_FILESYSTEM_DELETE_CONFIRM"));
                if (x) {
                    $scope.IsLoading = true;
                    $scope.showOverlay = true;
                    controller.Delete($scope.browseServiceName, id, function (data) {
                        $scope.resetActionMenu();
                        /*$scope.SelectedFileSystemId = null;*/
                        $scope.IsLoading = true;
                        $scope.showOverlay = true;
                        if ($scope.SelectedFolderChildren != null) {
                            for (var i = 0; i < $scope.SelectedFolderChildren.length; i++) {
                                if ($scope.SelectedFolderChildren[i].FileSystemId == id) {
                                    $scope.SelectedFolderChildren.splice(i, 1);
                                    break;
                                }
                            }
                        }
                        if (id != $scope.SelectedFileSystemId)
                            $scope.getFolderTree($scope.SelectedFileSystemId);
                        else {
                            $scope.SelectedFolderChildren = null;
                            $scope.SelectedFileSystemId = null;
                            $scope.SelectedFileSystemName = null;
                            $scope.getFolderTree();
                        }
                        $scope.IsLoading = false;
                        $scope.showOverlay = false;
                        $scope.safeApply();
                    }, function () { $scope.IsLoading = false; }, $scope.WorkingAreaQueryString);
                }
            };
            $scope.copyactionselectWA = function (id) {
                $scope.copyFSId = id;
                $scope.cutFSId = null;
                $scope.showWAlist = true;
                $scope.showOverlay = true;
                $scope.showactionmenu = false;
                $scope.safeApply();
            };
            $scope.moveactionselectWA = function (id) {
                $scope.copyFSId = null;
                $scope.cutFSId = id;
                $scope.showWAlist = true;
                $scope.showOverlay = true;
                $scope.showactionmenu = false;
                $scope.safeApply();
            };
            $scope.doactionWA = function (waid) {
                $scope.showWAlist = false;
                $scope.showOverlay = false;
                $scope.showactionmenu = false;
                if ($scope.copyFSId != null && $scope.cutFSId != null) {
                    alert("Erron in paste action. Try again please.");
                    $scope.cutFSId = null;
                    $scope.copyFSId = null;
                    return;
                }
                if ($scope.cutFSId != null)
                    $scope.Move($scope.cutFSId, null, null, null, waid);
                if ($scope.copyFSId != null)
                    $scope.Copy($scope.copyFSId, null, waid);
                $scope.cutFSId = null;
                $scope.copyFSId = null;
                $scope.resetActionMenu();
            };
            $scope.copyaction = function (id) {
                $scope.copyFSId = id;
                $scope.cutFSId = null;
                $scope.showactionmenu = false;
                $scope.showOverlay = false;
                $scope.safeApply();
            };
            $scope.cutaction = function (id) {
                $scope.cutFSId = id;
                $scope.copyFSId = null;
                $scope.showactionmenu = false;
                $scope.showOverlay = false;
                $scope.safeApply();
            };
            $scope.pasteaction = function (targetId) {
                if ($scope.copyFSId != null && $scope.cutFSId != null) {
                    alert("Erron in paste action. Try again please.");
                    $scope.cutFSId = null;
                    $scope.copyFSId = null;
                    return;
                }
                if ($scope.cutFSId != null)
                    $scope.Move($scope.cutFSId, targetId, $scope.SelectedFolderChildren);
                if ($scope.copyFSId != null)
                    $scope.Copy($scope.copyFSId, targetId);
                $scope.cutFSId = null;
                $scope.copyFSId = null;
                $scope.resetActionMenu();
            };
            $scope.renamefolderaction = function (targetId) {
                $scope.openFolder(targetId, true);
            };
            $scope.stopProp = function (event) {
                if (event && event.stopPropagation)
                    event.stopPropagation();
            };
            $scope.renameaction = function (event) {
                $scope.showrenamebox = true;
                $scope.closeActionMenu();
                if (event && event.stopPropagation)
                    event.stopPropagation();
            };
            $scope.closeActionMenu = function () {
                $scope.showWAlist = false;
                $scope.showactionmenu = false;
                $scope.showOverlay = false;
            };
            $scope.resetActionMenu = function () {
                $scope.closeActionMenu();
                $scope.showpaste = false;
                $scope.showcopy = false;
                $scope.showcut = false;
                $scope.showdelete = false;
                $scope.shownew = false;
                $scope.showopenfolder = false;
                $scope.showopenfile = false;
                $scope.showrenamefs = false;
                $scope.showrenamebox = false;
                $scope.actionMenuOpenedFromTree = false;
            };
            $scope.resourceTreeClick = function (event, data) {
                $scope.SelectedFileSystemId = data.arg2.node.data.Id;
                $scope.openFolder($scope.SelectedFileSystemId);
                $scope.closeActionMenu();
                $scope.safeApply();
            };
            $scope.visit = function (item, delegate) {
                if (item == null || item.children == null)
                    return;
                var len = item.children.length;
                delegate(item);
                for (var i = 0; i < len; i++) {
                    $scope.visit(item.children[i], delegate);
                }
            };
            $scope.unlockItem = function (id) {
                $scope.closeActionMenu();
                $scope.IsLoading = true;
                controller.CallPutAction($scope.browseServiceName, "Unlock", id, null, function (data) {
                    $scope.showOverlay = false;
                    $scope.IsLoading = false;
                    // $scope.openFolder();
                    $scope.SelectedFolderChildren.forEach(function (x) {
                        if (id == x.FileSystemId)
                            x.LockUser = null;
                    });
                }, function () {
                    $scope.IsLoading = false;
                    $scope.showOverlay = false;
                    MessagesModule.MessagesController.prototype.ShowMessageBox("Unlock Error!", MessagesModule.MessageBoxType.ERROR, "Error");
                }, $scope.WorkingAreaQueryString);
            };
            $scope.forceUnlockItem = function (id, callback) {
                $scope.closeActionMenu();
                $scope.IsLoading = true;
                controller.CallPutAction($scope.browseServiceName, "ForceUnlock", id, null, function (data) {
                    $scope.showOverlay = false;
                    $scope.IsLoading = false;
                    if ($scope.SelectedFolderChildren) {
                        $scope.SelectedFolderChildren.forEach(function (x) {
                            if (id == x.FileSystemId)
                                x.LockUser = null;
                        });
                    }
                    if ($scope.results) {
                        $scope.results.forEach(function (x) {
                            if (id == x.FileSystemId)
                                x.LockUser = null;
                        });
                    }
                    if (callback != null)
                        callback(id);
                }, function () {
                    $scope.IsLoading = false;
                    $scope.showOverlay = false;
                    MessagesModule.MessagesController.prototype.ShowMessageBox("Unlock Error!", MessagesModule.MessageBoxType.ERROR, "Error");
                }, $scope.WorkingAreaQueryString);
            };
            $scope.unlockall = function () {
                $scope.IsLoading = true;
                controller.CallPutAction("FileSystem", "ForceUnlockAll", null, null, function (data) {
                    $scope.IsLoading = false;
                    $scope.showOverlay = false;
                    MessagesModule.MessagesController.prototype.ShowMessageBox("Successfully unlocked", MessagesModule.MessageBoxType.SUCCESS, "");
                }, function () {
                    $scope.IsLoading = false;
                    $scope.showOverlay = false;
                    MessagesModule.MessagesController.prototype.ShowMessageBox("Unlock Error!", MessagesModule.MessageBoxType.ERROR, "Error");
                }, $scope.WorkingAreaQueryString);
            };
            $scope.onDrop = function ($event, $data, array, targetId, fromtree) {
                if (fromtree === void 0) { fromtree = false; }
                if ($data.ParentId != targetId && $data.FileSystemId != targetId)
                    $scope.Move($data.FileSystemId, targetId, array, fromtree);
            };
            $scope.resourceTreeMove = function (toMove, moveTo, moveMode) {
                if (toMove != null && moveTo != null && (moveMode != null && moveMode != '')) {
                    $scope.Move(toMove.data.Id, moveTo.data.Id, null, true);
                }
            };
            $scope.openFile = function (fsId) {
                var i = 0;
                var selectedItem = null;
                for (i = 0; i < $scope.SelectedFolderChildren.length; i++) {
                    if ($scope.SelectedFolderChildren[i].FileSystemId == fsId) {
                        selectedItem = $scope.SelectedFolderChildren[i];
                        break;
                    }
                }
                if (selectedItem != null) {
                    location.href = "/en/admin/" + ((selectedItem.FileSystemTypeId == 2) ? 'resources' : 'cms') + "/" + ((selectedItem.FileSystemTypeId == 2) ? 'ResourceEdit' : 'WebPageEdit') + "/" +
                        selectedItem.FileSystemId + "?idl=" + (($scope.IsDocumentLibrary) ? '1' : '0');
                }
            };
            $scope.Move = function (fsId, targetId, array, fromtree, waid) {
                if (array === void 0) { array = null; }
                if (fromtree === void 0) { fromtree = false; }
                $scope.IsLoading = true;
                $scope.showOverlay = true;
                var queryString = '';
                if (fsId != null && targetId != null) {
                    queryString += "&tId=" + targetId + "&idl=" + (($scope.IsDocumentLibrary) ? '1' : '0');
                    controller.CallPutAction("FileSystem", "Move", fsId, null, function (data) {
                        if (array != null && array.length > 0) {
                            var index = 0;
                            var indexToRemove = -1;
                            array.forEach(function (x) {
                                var found = false;
                                if (fsId == x.FileSystemId && !found) {
                                    indexToRemove = index;
                                }
                                index++;
                            });
                            if (indexToRemove > -1)
                                array.splice(indexToRemove, 1);
                        }
                        $scope.openFolder($scope.SelectedFileSystemId);
                        $scope.getFolderTree($scope.SelectedFileSystemId);
                    }, function () { }, $scope.WorkingAreaQueryString + queryString);
                }
                else //move to wa
                 if (fsId != null && waid != null) {
                    queryString += "&targetwa=" + waid + "&idl=" + (($scope.IsDocumentLibrary) ? '1' : '0');
                    controller.CallPutAction("FileSystem", "MoveToWa", fsId, null, function (data) {
                        var qredirect = (waid != '') ? "waId=" + waid : '';
                        var credirect = ($scope.IsDocumentLibrary) ? 'resources' : 'cms';
                        $scope.redirectToAction($scope.Language, "admin", credirect, 'resources', null, qredirect);
                    }, function () { }, $scope.WorkingAreaQueryString + queryString);
                }
                else
                    alert("One or more move item argument are wrong.");
            };
            $scope.Copy = function (fsId, targetId, waid) {
                $scope.IsLoading = true;
                $scope.showOverlay = true;
                var queryString = '';
                if (fsId != null && targetId != null) {
                    queryString += "&tId=" + targetId + "&idl=" + (($scope.IsDocumentLibrary) ? '1' : '0');
                    controller.CallPutAction("FileSystem", "Copy", fsId, null, function (data) {
                        $scope.openFolder($scope.SelectedFileSystemId);
                        $scope.getFolderTree($scope.SelectedFileSystemId);
                    }, function () { }, $scope.WorkingAreaQueryString + queryString);
                }
                else //copy to wa
                 if (fsId != null && waid != null) {
                    queryString += "&targetwa=" + waid + "&idl=" + (($scope.IsDocumentLibrary) ? '1' : '0');
                    controller.CallPutAction("FileSystem", "CopyToWa", fsId, null, function (data) {
                        var qredirect = (waid != '') ? "waId=" + waid : '';
                        var credirect = ($scope.IsDocumentLibrary) ? 'resources' : 'cms';
                        $scope.redirectToAction($scope.Language, "admin", credirect, 'resources', null, qredirect);
                        //http://localhost:84/en/admin/cms/resources?waId=5725b287-0abf-4fb7-93f0-866c5a9c7de2
                    }, function () { }, $scope.WorkingAreaQueryString + queryString);
                }
                else
                    alert("One or more move item argument are wrong.");
            };
            $scope.Rename = function (id, newName) {
                $scope.IsLoading = true;
                controller.CallPutAction($scope.browseServiceName, "Rename", id, null, function (data) {
                    if ($scope.showrenamebox)
                        $scope.resetActionMenu();
                    else {
                        $scope.getFolderTree($scope.SelectedFileSystemId);
                        $scope.IsLoading = false;
                        $scope.renameEnabled = false;
                    }
                }, function () { $scope.renameEnabled = false; }, $scope.WorkingAreaQueryString + "&n=" + newName);
            };
            $scope.addFolder = function (name) {
                $scope.IsLoading = true;
                controller.CallPostAction($scope.browseServiceName, "CreateFolder", $scope.SelectedFileSystemId, null, function (data) {
                    $scope.IsLoading = false;
                    $scope.getFolderTree($scope.SelectedFileSystemId);
                    $scope.openFolder($scope.SelectedFileSystemId);
                    $scope.actionMenuFSId = data.Data.FileSystemId;
                    $scope.renameaction();
                }, function () { $scope.IsLoading = false; }, $scope.WorkingAreaQueryString + "&n=" + name);
            };
            $scope.rightClickEvent = function (item, event) {
                $scope.resetActionMenu();
                $scope.showopenfolder = (item.FileSystemTypeId == 0);
                $scope.showopenfile = !$scope.showopenfolder;
                $scope.showunlock = (item.FileSystemTypeId != 0 && item.LockUser);
                $scope.showdelete = (item.FileSystemTypeId != 0 && !item.LockUser);
                $scope.shownew = false;
                $scope.showrenamefs = !item.LockUser;
                $scope.showrenamefolder = false;
                $scope.showpaste = (item.FileSystemTypeId == 0 && ($scope.copyFSId != null || $scope.cutFSId != null));
                $scope.showcopy = true; //(item.FileSystemTypeId != 0);
                $scope.showcut = true; //(item.FileSystemTypeId != 0);
                $scope.actionMenuOpenedFromTree = false;
                $scope.rightClickCommonAction(item.FileSystemId, event);
            };
            $scope.rightClickEventById = function (itemId, event) {
                if ($scope.copyFSId == null && $scope.cutFSId == null) {
                    if (event && event.preventDefault) {
                        event.preventDefault(); // Necessary. Allows us to drop.
                    }
                    if (event && event.stopPropagation) {
                        event.stopPropagation(); // Necessary. Allows us to drop.
                    }
                    return;
                }
                $scope.showopenfile = false;
                $scope.showunlock = false;
                $scope.shownew = false;
                $scope.showrenamefs = false;
                $scope.showrenamefolder = false;
                $scope.showpaste = ($scope.copyFSId != null || $scope.cutFSId != null);
                $scope.showcopy = false;
                $scope.showcut = false;
                $scope.showdelete = false;
                $scope.actionMenuOpenedFromTree = false;
                $scope.rightClickCommonAction(itemId, event);
            };
            $scope.rightClickRenameFolder = function (event, data, showall) {
                if (showall === void 0) { showall = true; }
                var tree = eval('$("#resource_tree").fancytree("getTree")');
                var node = tree.getNodeByKey(data);
                $scope.renameEnabled = false;
                var itemId = node.data.Id;
                $scope.SelectedFileSystemId = itemId;
                if (itemId == $scope.ResourcesRootModel.children[0].Id && !showall) {
                    if (event && event.preventDefault) {
                        event.preventDefault(); // Necessary. Allows us to drop.
                    }
                    if (event && event.stopPropagation) {
                        event.stopPropagation(); // Necessary. Allows us to drop.
                    }
                    return;
                }
                $scope.resetActionMenu();
                $scope.showrenamefolder = true;
                $scope.showdelete = (itemId != $scope.ResourcesRootModel.children[0].Id && (node.children == null || node.children.length == 0));
                $scope.showopenfolder = showall;
                $scope.showpaste = ($scope.copyFSId != null || $scope.cutFSId != null);
                $scope.showcopy = (itemId != $scope.ResourcesRootModel.children[0].Id);
                $scope.showcut = (itemId != $scope.ResourcesRootModel.children[0].Id);
                $scope.rightClickCommonAction(itemId, event);
            };
            $scope.rightClickCommonAction = function (itemId, event) {
                if (!event)
                    return;
                $scope.actionMenuFSId = itemId;
                $scope.menuTopPos = {
                    "top": (event.clientY + 15) + "px",
                    "left": (event.clientX - 55) + "px"
                };
                $scope.showOverlay = true;
                $scope.showactionmenu = true;
                $scope.safeApply();
                if (event.preventDefault) {
                    event.preventDefault(); // Necessary. Allows us to drop.
                }
                if (event.stopPropagation) {
                    event.stopPropagation(); // Necessary. Allows us to drop.
                }
            };
            $scope.resourceTreeAfterReload = function () {
                if ($scope.SelectedFileSystemId != null && $scope.SelectedFileSystemId != '')
                    $scope.activateNode($scope.SelectedFileSystemId);
            };
            $scope.confirmUploadFile = function () {
                controller.Put("FileSystem", $scope.FileModel.FileSystemId, $scope.FileModel, function (data) {
                    if ($scope.ShowBrowsePartial)
                        $scope.openFolder($scope.SelectedFileSystemId);
                    else
                        $scope.search();
                    $scope.UploadPartialVisibility = true;
                    $scope.UploadFilePermissionVisibility = false;
                }, null, $scope.WorkingAreaQueryString);
            };
            $scope.selectFileSystemCallBack = function (lang, fsId, name, filetypeid, mimetype, alternativeUrlId, waUrlId) {
                $scope.redirectToAction(lang, "admin", (filetypeid == 2) ? 'resources' : 'cms', (filetypeid == 2) ? 'ResourceEdit' : 'WebPageEdit', fsId, "idl=" + (($scope.IsDocumentLibrary) ? '1' : '0') + $scope.WorkingAreaQueryString);
            };
            $scope.openFolderFromSearch = function (fsId) {
                $scope.SelectedFileSystemId = fsId;
                $scope.getFolderTree($scope.SelectedFileSystemId);
                $scope.openFolder($scope.SelectedFileSystemId);
                $scope.ShowBrowsePartial = true;
            };
            $scope.openBrowse = function () {
                //$scope.ResourcesRootModel = null;
                //$scope.SelectedFolderChildren = null;
                //$scope.SelectedFileSystemId = null;
                //$scope.results = null;
                $scope.UploadPartialVisibility = false;
                $scope.UploadFilePermissionVisibility = false;
                $scope.resetActionMenu();
                /*     if ($scope.SelectedFileSystemId == null)
                         $scope.getFolderTree();
                     else */
                $scope.getFolderTree($scope.SelectedFileSystemId);
                $scope.openFolder($scope.SelectedFileSystemId);
                //$scope.getFolderTree();
                $scope.ShowBrowsePartial = true;
            };
            $scope.openSearch = function () {
                //$scope.ResourcesRootModel = null;
                //$scope.SelectedFolderChildren = null;
                //$scope.SelectedFileSystemId = null;
                //$scope.results = null;
                $scope.UploadPartialVisibility = true;
                $scope.UploadFilePermissionVisibility = false;
                $scope.search();
                $scope.ShowBrowsePartial = false;
            };
            $scope.getSearchParameters = function () {
                controller.CallGetAction("FileSystem", "SearchParameters", null, function (data) {
                    var pageNum = 1;
                    if (data != null && data.Data != null) {
                        var params = data.Data;
                        $scope.SearchingText = params.SearchingText;
                        if (params.ResourceFilterType.toString() == "IMAGE")
                            $scope.MimeOption = "I";
                        if (params.ResourceFilterType.toString() == "WEB_CONTENT")
                            $scope.MimeOption = "WC";
                        if (params.ResourceFilterType.toString() == "BINARY")
                            $scope.MimeOption = "B";
                        $scope.SelectedMimeType = params.MimeType;
                        $scope.SelectedFileSystemId = params.SelectedFileSystemId;
                        $scope.SelectedFileSystemName = params.SelectedFileSystemName;
                        pageNum = params.CurrentPage;
                        $scope.RecordPerPage = params.RecordPerPage;
                        $scope.paging.currentPage = pageNum;
                        $scope.sortDirection = params.sSortDirection;
                        $scope.sortSelectedItem = params.SortKey;
                        $scope.getFolderTree($scope.SelectedFileSystemId);
                        if (params.LoadFolder) {
                            $scope.openBrowse();
                            if ($scope.SearchingText != "") {
                                $scope.ShowSearchSection = true;
                                $scope.openFolder($scope.SelectedFileSystemId);
                            }
                        }
                        else
                            $scope.search(pageNum);
                    }
                    else {
                        $scope.openBrowse();
                    }
                }, function () { }, null);
            };
            if (_this.GetParameterByName('bfd') == '1') {
                $scope.getSearchParameters();
            }
            else
                $scope.openBrowse(); //$scope.search();
            return _this;
        }
        return ResourcesController;
    }(ContentResourceSearchModule.ContentSearchResource));
    ResourcesModule.ResourcesController = ResourcesController;
})(ResourcesModule || (ResourcesModule = {}));
angular.module('minervaApp').controller("ResourcesModule.ResourcesController", ["$scope", "$http", "$timeout", ResourcesModule.ResourcesController]);
//ResourcesController.js.map;
/*! WebContentResourceSearchController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var ResourcesModule;
(function (ResourcesModule) {
    // This controller is used by the TinyMCE modal box, to create link and insert image in the HTML
    var WebContentResourceSearchController = /** @class */ (function (_super) {
        __extends(WebContentResourceSearchController, _super);
        function WebContentResourceSearchController($scope, $http, $timeout) {
            var _this = this;
            //file || image
            $scope.IsDocumentLibrary = false;
            _this = _super.call(this, $scope, $http, $timeout) || this;
            var controller = _this;
            // override of the select resource callback. The base method open the page, this return the link of the resource to the caller
            $scope.selectFileSystemCallBack = function (lang, fsId, name, filetypeid, mimetype, alternativeUrlId, waUrlId) {
                var url = "/" + lang + "/shorturl/" + waUrlId + "/" + alternativeUrlId;
                var field_name = eval("winbrowser.params.input");
                var win = eval("winbrowser.params.window");
                win.document.getElementById(field_name).value = url;
                eval("winbrowser.close()");
            };
            return _this;
        }
        return WebContentResourceSearchController;
    }(ResourcesModule.ResourcesController));
    ResourcesModule.WebContentResourceSearchController = WebContentResourceSearchController;
})(ResourcesModule || (ResourcesModule = {}));
angular.module('minervaApp').controller("ResourcesModule.WebContentResourceSearchController", ["$scope", "$http", ResourcesModule.WebContentResourceSearchController]);
//WebContentResourceSearchController.js.map;
/*! AdminCMSEventController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var AdminModule;
(function (AdminModule) {
    var CMSEventController = /** @class */ (function (_super) {
        __extends(CMSEventController, _super);
        function CMSEventController($scope, $http, $filter) {
            var _this = _super.call(this, $scope, $http, "Admin", "CMSEvent", false) || this;
            var controller = _this;
            $scope.dateOptions = {
                dateDisabled: false,
                startingDay: 1,
                minDate: Date.now(),
                showWeeks: false,
                isStartOpen: false,
                isEndOpen: false
            };
            $scope.Model = new Module.CMS.VMEvent();
            $scope.EventTypeCode = $scope.urlVars[5];
            $scope.IdModel = $scope.urlVars[6];
            $scope.WorkingAreaId = "";
            var waId = controller.GetParameterByName('waId');
            if (waId != null && waId != '' && waId != 'undefined') {
                $scope.WorkingAreaId = waId;
                $scope.WorkingAreaQueryString = "waId=" + waId;
            }
            else
                $scope.WorkingAreaId = MinervaWorkingAreaId;
            $scope.beforeSaveCallBack = function () {
                if ($scope.Model.WorkingAreaId == null)
                    $scope.Model.WorkingAreaId = waId;
                $scope.Model.Translations = $scope.Model.Translations.filter(function (x) { return x.Title != ''; });
            };
            $scope.afterSaveCallBack = function (data) {
                controller.RedirectToAction($scope.Language, $scope.areaName, $scope.serviceName, 'list', $scope.EventTypeCode, $scope.WorkingAreaQueryString);
            };
            // callback method called after a new save, to redirect the page in the edit mode
            $scope.addModelCallBack = function (data) {
                controller.RedirectToAction($scope.Language, $scope.areaName, $scope.serviceName, 'list', $scope.EventTypeCode, $scope.WorkingAreaQueryString);
            };
            // Implements check super mandatory cmsContent fields function
            $scope.checkMandatoryFields = function (successCallBack) {
                var trans = $scope.Model.Translations.filter(function (x) { return x.Language.LanguageId == 'EN'; })[0];
                if (trans == null || trans.Title == null || $scope.Model.Type == null || $scope.Model.Address == null) {
                    var errorMessage = controller.GetMessage("UM_MANDATORY_NOT_FILLED");
                    MessagesModule.MessagesController.prototype.ShowMessageBox(errorMessage, MessagesModule.MessageBoxType.ERROR);
                }
                else if (!isURL($scope.Model.Link)) {
                    var errorMessage = controller.GetMessage("MINERVA_CMS_EVENT_URL_INVALID");
                    MessagesModule.MessagesController.prototype.ShowMessageBox(errorMessage, MessagesModule.MessageBoxType.ERROR);
                }
                else {
                    successCallBack();
                }
            };
            var isURL = function (str) {
                if (!str)
                    return true;
                var pattern = new RegExp('(http|https):\/\/(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(\/|\/([\\w#!:.?+=&%@!\-\/]))?', 'gi');
                return pattern.test(str);
            };
            // Discard changes
            $scope.discardChanges = function () {
                var url = controller.CreateUrl($scope.Language, $scope.areaName, $scope.serviceName, 'list', $scope.EventTypeCode, $scope.WorkingAreaQueryString);
                if ($scope.IsNew) {
                    controller.Delete('FileSystem', $scope.Model.FolderId, function (data) {
                    }, null, $scope.WorkingAreaQueryString);
                }
                if ($scope.wasChanged) {
                    MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("MINERVA_DISCARD_QUESTION"), MessagesModule.MessageBoxType.YESNO, "", function () {
                        $scope.forceExit = true;
                        controller.RedirectToUrl(url);
                    });
                }
                else {
                    $scope.forceExit = true;
                    controller.RedirectToUrl(url);
                }
            };
            $scope.delete = function () {
                MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage('MINERVA_CMS_' + $scope.EventTypeCode.toUpperCase() + '_DELETE'), MessagesModule.MessageBoxType.YESNO, "", function () {
                    controller.Delete($scope.serviceName, $scope.Model.EventId, function (data) {
                        controller.RedirectToAction($scope.Language, $scope.areaName, $scope.serviceName, 'list', $scope.EventTypeCode, $scope.WorkingAreaQueryString);
                    });
                });
            };
            $scope.getNewInstance = function () {
                var query = $scope.WorkingAreaQueryString + '&typeCode=' + $scope.EventTypeCode;
                controller.CallGetAction($scope.serviceName, "NewInstance", null, function (data) {
                    $scope.Model = data.Data;
                    $scope.getModelCallBack($scope.Model);
                }, null, query);
                return true;
            };
            $scope.toggleFullDay = function () {
                $scope.Model.StartDate = moment($scope.Model.StartDate).format(($scope.Model.FullDay ? 'D MMMM YYYY' : 'D MMMM YYYY 12:00'));
                $scope.Model.EndDate = moment($scope.Model.EndDate).format(($scope.Model.FullDay ? 'D MMMM YYYY' : 'D MMMM YYYY 12:30'));
            };
            $scope.loadEventTypes = function () {
                controller.CallGetAction($scope.serviceName, "ListEventTypes", null, function (data) {
                    $scope.EventTypes = data.Data;
                }, null, null);
            };
            $scope.loadEventTypes();
            $scope.getModelCallBack = function (model) {
                SetSelectedTranslation('EN');
                $scope.Model.ImageThumb = $scope.Model.AttachmentsThumb = null;
            };
            var SetSelectedTranslation = function (Language) {
                $scope.selectedTranslation = null;
                if ($scope.Model == null)
                    return;
                if ($scope.Model.Translations == null)
                    $scope.Model.Translations = [];
                if ($scope.Model.Translations.length > 0)
                    $scope.selectedTranslation = $scope.Model.Translations.filter(function (x) { return x.Language.LanguageId == Language; })[0];
                if ($scope.selectedTranslation == null && $scope.selectedLanguage) {
                    $scope.Model.Translations.push({
                        EventId: $scope.Model.EventId,
                        Language: $scope.selectedLanguage,
                        Title: '',
                        Description: ''
                    });
                    $scope.selectedTranslation = $scope.Model.Translations.slice(-1).pop();
                }
            };
            $scope.loadPage = function () {
                $scope.IsNew = ($scope.IdModel == undefined || $scope.IdModel == null || $scope.IdModel == '');
                if (!$scope.IsNew) {
                    $scope.getModel($scope.IdModel);
                }
                else {
                    $scope.getNewInstance();
                }
            };
            // Initialize the page
            $scope.loadPage();
            _this.GetCache("TRANSLATEDLANGUAGES", function (data) {
                $scope.Languages = data.Data;
                $scope.selectedLanguage = $scope.Languages.filter(function (x) { return x.LanguageId == 'EN'; })[0];
            });
            $scope.dateChanged = function () {
                $scope.Model.EndDate = moment(new Date($scope.Model.StartDate).getTime() + 30 * 60000).format('D MMMM YYYY HH:mm');
            };
            $scope.$watch('selectedLanguage', function (newValue, oldValue) {
                if (newValue == oldValue)
                    return;
                SetSelectedTranslation($scope.selectedLanguage.LanguageId);
            });
            $scope.addAttachment = function (newfile) {
                if (!$scope.Model.AttachmentsThumb)
                    $scope.Model.AttachmentsThumb = [];
                $scope.Model.AttachmentsThumb.push({
                    Name: newfile.Data[3],
                    Extension: newfile.Data[2].Extension,
                    MimeTypeId: newfile.Data[2].MimeTypeId,
                    ThumbUrl: createThumbUrl(newfile)
                });
            };
            $scope.updateImage = function (newfile) {
                if (newfile.Type == 1) {
                    alert(newfile.Message);
                    return;
                }
                $scope.Model.ImageThumb = {
                    Name: newfile.Data[3],
                    Extension: newfile.Data[2].Extension,
                    MimeTypeId: newfile.Data[2].MimeTypeId,
                    ThumbUrl: createThumbUrl(newfile)
                };
            };
            var createThumbUrl = function (file) {
                return 'cId=' + file.Data[3] + '&lId=' + file.Data[0] + '&fn=' + file.Data[3];
            };
            return _this;
        }
        return CMSEventController;
    }(BaseModule.CrudBaseController));
    AdminModule.CMSEventController = CMSEventController;
})(AdminModule || (AdminModule = {}));
angular.module('minervaApp').controller("AdminModule.CMSEventController", ["$scope", "$http", "$filter", AdminModule.CMSEventController]);
//AdminCMSEventController.js.map;
/*! AdminCMSEventSearchController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var AdminModule;
(function (AdminModule) {
    /**********************************   SEARCH/VIEW CONTROLLER ********************************************/
    var CMSEventSearchController = /** @class */ (function (_super) {
        __extends(CMSEventSearchController, _super);
        function CMSEventSearchController($scope, $http, $timeout) {
            var _this = this;
            $scope.searchServiceName = "CMSEvent";
            _this = _super.call(this, $scope, $http, false) || this;
            var controller = _this;
            $scope.WorkingAreaId = "";
            var waId = controller.GetParameterByName('waId');
            if (waId != null && waId != '' && waId != 'undefined') {
                $scope.WorkingAreaId = waId;
                $scope.WorkingAreaQueryString = "?waId=" + waId;
            }
            $scope.EventTypeCode = $scope.urlVars[5];
            // Method called to search cms content
            $scope.list = function (pageNr) {
                if (pageNr === void 0) { pageNr = null; }
                if (pageNr == null || pageNr < 1)
                    pageNr = 1;
                // add searching parameter to query string
                var query = "";
                query = query + "waId=" + $scope.WorkingAreaId;
                query = query + "&typeCode=" + $scope.EventTypeCode;
                query = query + "&currentPage=" + pageNr;
                query = query + "&rpp=" + $scope.RecordPerPage;
                query = query + "&sortby=" + $scope.sortSelectedItem;
                query = query + "&sortdir=" + $scope.sortDirection;
                controller.List($scope.searchServiceName, function (data) {
                    var searchResult = data.Data;
                    $scope.paging.maxPages = searchResult.maxPages;
                    $scope.paging.currentPage = searchResult.currentPage;
                    $scope.paging.totlaResults = searchResult.totlaResults;
                    $scope.paging.GetSelectablePages();
                    $scope.results = searchResult.resultSet;
                }, null, true, query);
            };
            $scope.list();
            // reset all search filters and call a new searh
            $scope.resetSearch = function () {
                $scope.paging.currentPage = 1;
                $scope.SearchingText = "";
                $scope.search();
            };
            $scope.delete = function (eventId) {
                MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage('MINERVA_CMS_' + $scope.EventTypeCode.toUpperCase() + '_DELETE'), MessagesModule.MessageBoxType.YESNO, "", function () {
                    controller.Delete($scope.searchServiceName, eventId, function (data) {
                        $scope.list($scope.paging.currentPage);
                    }, null, $scope.WorkingAreaQueryString);
                });
            };
            $scope.togglePublish = function (eventId) {
                controller.CallPostAction($scope.searchServiceName, "TogglePublish", eventId, null, function (data) {
                    $scope.list($scope.paging.currentPage);
                }, null, $scope.WorkingAreaQueryString);
                return true;
            };
            $scope.getTranslation = function (Object, Language, Key) {
                var trans = null;
                trans = Object.Translations.filter(function (x) { return x.Language.LanguageId == Language; })[0];
                if (trans == null)
                    trans = Object.Translations.filter(function (x) { return x.Language.LanguageId == 'EN'; })[0];
                var value = eval('trans[Key]');
                var isLong = (value.length > 256);
                return value.substr(0, 255) + (isLong ? '...' : '');
            };
            return _this;
        }
        return CMSEventSearchController;
    }(SearchModule.GenericSearchController));
    AdminModule.CMSEventSearchController = CMSEventSearchController;
})(AdminModule || (AdminModule = {}));
angular.module('minervaApp').controller("AdminModule.CMSEventSearchController", ["$scope", "$http", AdminModule.CMSEventSearchController]);
//AdminCMSEventSearchController.js.map;
/*! AdminForumController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
/// <reference path='../../tsmodels/Admin/Forum/VMForum.ts' /> 
var AdminForumModule;
(function (AdminForumModule) {
    var AdminForumController = /** @class */ (function (_super) {
        __extends(AdminForumController, _super);
        function AdminForumController($scope, $http) {
            var _this = 
            // Load base CRUD methods and properties
            _super.call(this, $scope, $http, "Admin", "Rss", false) || this;
            var controller = _this;
            $scope.WorkingAreaId = "";
            var waId = controller.GetParameterByName('waId');
            if (waId != null && waId != '' && waId != 'undefined') {
                $scope.WorkingAreaId = waId;
                $scope.WorkingAreaQueryString = "waId=" + waId;
                $scope.AddModelQueryString = $scope.WorkingAreaQueryString;
                $scope.UpdateModelQueryString = $scope.WorkingAreaQueryString;
                $scope.UnlockModelQueryString = $scope.WorkingAreaQueryString;
                $scope.LockModelQueryString = $scope.WorkingAreaQueryString;
                $scope.GetModelQueryString = $scope.WorkingAreaQueryString;
            }
            $scope.serviceName = "forum";
            $scope.Model = new Module.Admin.Forum.VMForum();
            $scope.HasTransactions = false;
            try {
                $scope.RecordPerPage = parseInt($("#rpp_def").val());
            }
            catch (e) {
            }
            $scope.paging = new PagingModule.PagingController();
            // mandatory callbacks
            // callback method called  after a lock
            $scope.lockModelCallBack = function () { };
            $scope.beforeSaveCallBack = function () { };
            $scope.afterSaveCallBack = function (data) {
                $scope.Model = data;
                $scope.safeApply();
            };
            $scope.lockModelErrorCallBack = function () { };
            // Implements check super mandatory cmsContent fields function
            $scope.checkMandatoryFields = function (successCallBack) {
                if ($scope.Model.ForumTitle == null) {
                    var errorMessage = controller.GetMessage("UM_MANDATORY_NOT_FILLED");
                    MessagesModule.MessagesController.prototype.ShowMessageBox(errorMessage, MessagesModule.MessageBoxType.ERROR);
                }
                else {
                    successCallBack();
                }
            };
            // Discard changes
            $scope.discardForumChanges = function (area, controllerName, action, id, queryString) {
                if (action === void 0) { action = null; }
                if (id === void 0) { id = null; }
                if (queryString === void 0) { queryString = null; }
                var url = controller.CreateUrl($scope.Language, area, controllerName, action, id, queryString);
                if ($scope.wasChanged) {
                    MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("MINERVA_DISCARD_QUESTION"), MessagesModule.MessageBoxType.YESNO, "", function () {
                        if (id == null)
                            id = $scope.IdModel;
                        $scope.forceExit = true;
                        controller.RedirectToUrl(url);
                    });
                }
                else {
                    $scope.forceExit = true;
                    controller.RedirectToUrl(url);
                }
            };
            // callback method called after a new forum save, to redirect the page in the edit mode
            $scope.addModelCallBack = function (data) {
                //Decoupling merge with rev. 4300
                //controller.RedirectToAction($scope.Language, 'admin', 'forum', 'list', data.ForumId, $scope.WorkingAreaQueryString);
                controller.RedirectToAction($scope.Language, 'admin', 'forum', 'list', null, $scope.WorkingAreaQueryString);
                //END Decoupling merge with rev. 4300
            };
            // Delete the forum
            $scope.deleteForum = function () {
                MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("UM_ROLE_DELETE_QUESTION"), MessagesModule.MessageBoxType.YESNO, "", function () {
                    controller.Delete("forum", $scope.Model.ForumId, function (data) {
                        controller.RedirectToAction($scope.Language, 'admin', 'forum', 'list', null, $scope.WorkingAreaQueryString);
                    });
                });
            };
            // Get a new forum emppty but initialized instance
            $scope.getNewForumInstance = function () {
                controller.CallGetAction($scope.serviceName, "NewInstance", null, function (data) {
                    $scope.Model = data.Data;
                    $scope.Model.MinimumThreadList = 5;
                    $scope.Model.MostPopularNumber = 2;
                    $scope.Model.IsActive = true;
                    $scope.Model.IsPublished = true;
                }, null, $scope.WorkingAreaQueryString);
                return true;
            };
            // Load the page with the forum id or with a new forum instance
            $scope.loadPage = function () {
                $scope.IsNew = ($scope.urlVars[5] == undefined || $scope.urlVars[5] == null || $scope.urlVars[5] == '');
                $scope.IsEdit = !$scope.IsNew;
                if ($scope.IsEdit) {
                    $scope.IdModel = $scope.urlVars[5];
                    $scope.getModel($scope.IdModel);
                }
                else {
                    $scope.getNewForumInstance();
                }
            };
            // Initialize the page
            $scope.loadPage();
            return _this;
        }
        return AdminForumController;
    }(BaseModule.CrudBaseController));
    AdminForumModule.AdminForumController = AdminForumController;
})(AdminForumModule || (AdminForumModule = {}));
angular.module('minervaApp').controller("AdminRssModule.AdminForumController", ["$scope", "$http", AdminForumModule.AdminForumController]);
//AdminForumController.js.map;
/*! AdminForumSearchController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var AdminRssModule;
(function (AdminRssModule) {
    /**********************************   SEARCH/VIEW CONTROLLER ********************************************/
    var AdminForumSearchController = /** @class */ (function (_super) {
        __extends(AdminForumSearchController, _super);
        function AdminForumSearchController($scope, $http, $timeout) {
            var _this = this;
            $scope.searchServiceName = "Forum";
            _this = _super.call(this, $scope, $http, false) || this;
            var controller = _this;
            $scope.WorkingAreaId = "";
            var waId = controller.GetParameterByName('waId');
            if (waId != null && waId != '' && waId != 'undefined') {
                $scope.WorkingAreaId = waId;
                $scope.WorkingAreaQueryString = "?waId=" + waId;
            }
            // Method called to search cms content
            $scope.list = function (pageNr) {
                if (pageNr === void 0) { pageNr = null; }
                if (pageNr == null || pageNr < 1)
                    pageNr = 1;
                // add searching parameter to query string
                var query = "";
                query = query + "waId=" + $scope.WorkingAreaId;
                query = query + "&currentPage=" + pageNr;
                query = query + "&rpp=" + $scope.RecordPerPage;
                query = query + "&sortby=" + $scope.sortSelectedItem;
                query = query + "&sortdir=" + $scope.sortDirection;
                controller.List($scope.searchServiceName, function (data) {
                    var searchResult = data.Data;
                    $scope.paging.maxPages = searchResult.maxPages;
                    $scope.paging.currentPage = searchResult.currentPage;
                    $scope.paging.totlaResults = searchResult.totlaResults;
                    $scope.paging.GetSelectablePages();
                    $scope.results = searchResult.resultSet;
                }, null, true, query);
            };
            // reset all search filters and call a new searh
            $scope.resetSearch = function () {
                $scope.paging.currentPage = 1;
                $scope.SearchingText = "";
                $scope.search();
            };
            $scope.deleteForum = function (forumId) {
                MessagesModule.MessagesController.prototype.ShowMessageBox("Are you sure to delete the current forum", MessagesModule.MessageBoxType.YESNO, "", function () {
                    controller.Delete($scope.searchServiceName, forumId, function (data) {
                        $scope.list($scope.paging.currentPage);
                    }, null, $scope.WorkingAreaQueryString);
                });
            };
            $scope.togglePublishForum = function (forumId) {
                controller.CallPostAction($scope.searchServiceName, "TogglePublishForum", forumId, null, function (data) {
                    $scope.list($scope.paging.currentPage);
                }, null, $scope.WorkingAreaQueryString);
                return true;
            };
            $scope.toggleHighlighForum = function (forumId) {
                controller.CallPostAction($scope.searchServiceName, "ToggleHighlighForum", forumId, null, function (data) {
                    $scope.list($scope.paging.currentPage);
                }, null, $scope.WorkingAreaQueryString);
                return true;
            };
            $scope.list();
            return _this;
        }
        return AdminForumSearchController;
    }(SearchModule.GenericSearchController));
    AdminRssModule.AdminForumSearchController = AdminForumSearchController;
})(AdminRssModule || (AdminRssModule = {}));
angular.module('minervaApp').controller("AdminRssModule.AdminForumSearchController", ["$scope", "$http", AdminRssModule.AdminForumSearchController]);
//AdminForumSearchController.js.map;
/*! AdminHttpController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var AdminHttpModule;
(function (AdminHttpModule) {
    var BrowserController = /** @class */ (function (_super) {
        __extends(BrowserController, _super);
        function BrowserController($scope, $http, $timeout) {
            var _this = this;
            $scope.searchServiceName = "Browser";
            _this = _super.call(this, $scope, $http) || this;
            var controller = _this;
            $scope.search = function () {
                controller.CallGetAction("Http", "Browser", null, function (data) {
                    $scope.results = data.Data;
                    $scope.safeApply();
                });
            };
            $scope.search();
            return _this;
        }
        return BrowserController;
    }(SearchModule.GenericSearchController));
    AdminHttpModule.BrowserController = BrowserController;
    var RequestController = /** @class */ (function (_super) {
        __extends(RequestController, _super);
        function RequestController($scope, $http, $timeout) {
            var _this = this;
            $scope.searchServiceName = "Requests";
            _this = _super.call(this, $scope, $http) || this;
            var controller = _this;
            $scope.search = function (pageNr) {
                if (pageNr === void 0) { pageNr = null; }
                if (pageNr == null || pageNr < 1)
                    pageNr = 1;
                // add searching parameter to query string
                var query = "";
                query = query + "searchingtext=" + ($scope.SearchingText != undefined ? encodeURIComponent($scope.SearchingText) : '');
                query = query + "&roleId=" + ($scope.SelectedRole != undefined ? encodeURIComponent($scope.SelectedRole) : '');
                query = query + "&statusId=" + ($scope.SelectedStatus != undefined ? encodeURIComponent($scope.SelectedStatus) : '');
                query = query + "&countryId=" + ($scope.Country != undefined ? encodeURIComponent($scope.Country) : '');
                query = query + "&currentPage=" + pageNr;
                query = query + "&rpp=" + $scope.RecordPerPage;
                controller.Search("Http", query, function (data) {
                    ///controller.CallGetAction("Http", "Requests", null, function (data) {
                    var searchResult = data.Data;
                    $scope.paging.maxPages = searchResult.maxPages;
                    $scope.paging.currentPage = searchResult.currentPage;
                    $scope.paging.totlaResults = searchResult.totlaResults;
                    $scope.paging.GetSelectablePages();
                    $scope.results = searchResult.resultSet;
                    $scope.safeApply();
                });
            };
            // reset all search filters and call a new searh
            $scope.resetSearch = function () {
                $scope.paging.currentPage = 1;
                $scope.SearchingText = "";
                $scope.search();
            };
            $scope.search();
            return _this;
        }
        return RequestController;
    }(SearchModule.GenericSearchController));
    AdminHttpModule.RequestController = RequestController;
})(AdminHttpModule || (AdminHttpModule = {}));
angular.module('minervaApp').controller("AdminHttpModule.BrowserController", ["$scope", "$http", AdminHttpModule.BrowserController]);
angular.module('minervaApp').controller("AdminHttpModule.RequestController", ["$scope", "$http", AdminHttpModule.RequestController]);
//AdminHttpController.js.map;
/*! AdminRoleController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var AdminRoleModule;
(function (AdminRoleModule) {
    var AdminRoleController = /** @class */ (function (_super) {
        __extends(AdminRoleController, _super);
        function AdminRoleController($scope, $http) {
            var _this = 
            // Load base CRUD methods and properties
            _super.call(this, $scope, $http, "Admin", "Role", true) || this;
            var controller = _this;
            $scope.Model = new Module.VMAdminRole();
            //$scope.LogSearchCriteria = "1";
            $scope.SelectedLanguage = "EN";
            $scope.HasTransactions = false;
            try {
                $scope.RecordPerPage = parseInt($("#rpp_def").val());
            }
            catch (e) {
            }
            $scope.paging = new PagingModule.PagingController();
            //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
            // * * * * * * * * * * * * * * * * * * * * *   Base class methods implementation  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
            //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
            // callback method called  after a lock
            $scope.lockModelCallBack = function () {
                $scope.scanProfiles();
            };
            // mandatory callbacks
            $scope.beforeSaveCallBack = function () { };
            $scope.afterSaveCallBack = function () { };
            $scope.lockModelErrorCallBack = function () { };
            // Implements check super mandatory cmsContent fields function
            $scope.checkMandatoryFields = function (successCallBack) {
                if ($scope.Model.Name == null) {
                    var errorMessage = controller.GetMessage("UM_MANDATORY_NOT_FILLED");
                    MessagesModule.MessagesController.prototype.ShowMessageBox(errorMessage, MessagesModule.MessageBoxType.ERROR);
                }
                else {
                    successCallBack();
                }
            };
            // callback method called after a new establishment save, to redirect the page in the edit mode
            $scope.addModelCallBack = function (data) {
                controller.RedirectToAction($scope.Language, 'admin', 'role', 'edit', data.RoleId);
            };
            // Method called to search cms content
            $scope.searchAdminUsers = function (pageNr) {
                if (pageNr === void 0) { pageNr = null; }
                if (pageNr == null || pageNr < 1)
                    pageNr = 1;
                // add searching parameter to query string
                var query = "";
                query = query + "searchingtext=" + ($scope.SearchingText != undefined ? encodeURIComponent($scope.SearchingText) : '');
                query = query + "&language=" + ($scope.SelectedLanguage != undefined ? $scope.SelectedLanguage : '');
                query = query + "&currentPage=" + pageNr;
                query = query + "&rpp=" + $scope.RecordPerPage;
                controller.Search("Cms", query, function (data) {
                    var searchResult = data.Data;
                    $scope.paging.maxPages = searchResult.maxPages;
                    $scope.paging.currentPage = searchResult.currentPage;
                    $scope.paging.totlaResults = searchResult.totlaResults;
                    $scope.paging.GetSelectablePages();
                    $scope.AdminUsers = searchResult.resultSet;
                });
            };
            // call back after selecting a user from the autcomplete box
            $scope.adduserAutocompleteSelectCallBack = function (item) {
                if (item == null) {
                    $scope.SelectedUser = new Module.VMUserRole();
                    $scope.safeApply();
                }
                else {
                    $scope.SelectedUser = item;
                    $scope.wasChanged = true;
                    $scope.safeApply();
                }
            };
            // get the user and add it to the  list
            $scope.addUser = function () {
                if ($scope.SelectedUser == null || $scope.Model == null)
                    return;
                controller.CallGetAction("User", "GetUser", $scope.SelectedUser.UserId, function (data) {
                    if (data.Data.Role == null || data.Data.Role.RoleId == null)
                        $scope.addUserToList();
                    if (data.Data.IsLocked && !data.Data.IsLockedByMe) {
                        MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("UM_ROLE_ADD_USER_LOCKED"), MessagesModule.MessageBoxType.WARNING);
                        return;
                    }
                    if (data.Data.Role != null && data.Data.Role.RoleId != null && data.Data.Role.RoleId != $scope.Model.RoleId) {
                        var errormessage = controller.GetMessage("UM_ROLE_ADD_USER_WITH_ANOTHER_ROLE_QUESTION");
                        errormessage = errormessage.replace("{0}", data.Data.Role.Name);
                        MessagesModule.MessagesController.prototype.ShowMessageBox(errormessage, MessagesModule.MessageBoxType.YESNO, "", function () {
                            $scope.addUserToList();
                        });
                    }
                });
            };
            // add the user to the list
            $scope.addUserToList = function () {
                if ($scope.Model.Users == null) {
                    $scope.Model.Users = new Array($scope.SelectedUser);
                    return;
                }
                var i = 0;
                for (i = 0; i < $scope.Model.Users.length; i++) {
                    if ($scope.Model.Users[i].UserId == $scope.SelectedUser.UserId) {
                        $scope.SelectedUser = new Module.VMUserRole();
                        return;
                    }
                }
                if ($scope.Model.Users.length == 0) {
                    $scope.Model.Users.splice(-1, 0, $scope.SelectedUser);
                    $scope.SelectedUser = new Module.VMUserRole();
                    $scope.wasChanged = true;
                    $scope.safeApply();
                    return;
                }
                var i = 0;
                var inserted = false;
                for (i = 0; i < $scope.Model.Users.length; i++) {
                    $scope.Model.Users.splice(i, 0, $scope.SelectedUser);
                    inserted = true;
                    break;
                }
                if (!inserted)
                    $scope.Model.Users.splice(i, 0, $scope.SelectedUser);
                $scope.SelectedUser = new Module.VMUserRole();
                $scope.wasChanged = true;
                $scope.safeApply();
            };
            // remove the user to the list
            $scope.removeUser = function (id) {
                MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("UM_ROLE_REMOVE_USER_QUESTION"), MessagesModule.MessageBoxType.YESNO, "", function () {
                    controller.CallPutAction($scope.serviceName, "UnassignUser", $scope.Model.RoleId, $scope.Model, function (data) {
                        if (data.Data) {
                            if ($scope.Model == null
                                || $scope.Model.Users == null || $scope.Model.Users.length < 1)
                                return;
                            var i = 0;
                            var index = 0;
                            for (i = 0; i < $scope.Model.Users.length; i++) {
                                if ($scope.Model.Users[i].UserId == id) {
                                    index = i;
                                    break;
                                }
                            }
                            $scope.Model.Users.splice(index, 1);
                            $scope.wasChanged = true;
                            $scope.safeApply();
                        }
                    }, null, "uid=" + id);
                });
            };
            $scope.isCountryRequired = function () {
                if ($scope.Model == null || $scope.Model.ProfileApplications == null)
                    return false;
                var i = 0;
                var j = 0;
                for (i = 0; i < $scope.Model.ProfileApplications.length; i++) {
                    for (j = 0; j < $scope.Model.ProfileApplications[i].Rights.length; j++) {
                        if ($scope.Model.ProfileApplications[i].Rights[j].Selected)
                            if ($scope.Model.ProfileApplications[i].Rights[j].IsCountryRequired)
                                return true;
                    }
                }
                return false;
            };
            $scope.scanProfiles = function (id) {
                if (id === void 0) { id = ''; }
                if ($scope.Model.ProfileApplications == null || id == null || id == '')
                    return;
                $scope.requireCountryProfileList = new Array();
                var i = 0;
                var j = 0;
                for (i = 0; i < $scope.Model.ProfileApplications.length; i++) {
                    if ($scope.Model.ProfileApplications[i].Rights != null)
                        for (j = 0; j < $scope.Model.ProfileApplications[i].Rights.length; j++) {
                            //if (id == "ESPIRS_ACT_AS_NATIONAL_REPORTER" &&
                            //    ($scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_NATIONAL_ADMINISTRATOR" ||
                            //    $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_MAHB")) {
                            //    $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            //}
                            //if (id == "ESPIRS_ACT_AS_NATIONAL_ADMINISTRATOR" &&
                            //    ($scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_NATIONAL_REPORTER" ||
                            //    $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_MAHB")) {
                            //    $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            //}
                            //if (id == "ESPIRS_ACT_AS_MAHB" &&
                            //    ($scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_NATIONAL_ADMINISTRATOR" ||
                            //    $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_NATIONAL_REPORTER")) {
                            //    $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            //}
                            if (id == "ESPIRS_ACT_AS_MAHB" &&
                                ($scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_NATIONAL_ADMINISTRATOR" ||
                                    $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_NATIONAL_REPORTER" ||
                                    $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_READ_ONLY" ||
                                    $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_READ_ONLY_FOR_COUNTRY" ||
                                    $scope.Model.ProfileApplications[i].Rights[j].Right == "IMPORT_ESTABLISHMENT"))
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            if (id == "ESPIRS_ACT_AS_NATIONAL_REPORTER" &&
                                ($scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_MAHB" ||
                                    $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_NATIONAL_ADMINISTRATOR" ||
                                    $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_READ_ONLY" ||
                                    $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_READ_ONLY_FOR_COUNTRY" ||
                                    $scope.Model.ProfileApplications[i].Rights[j].Right == "IMPORT_ESTABLISHMENT"))
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            if (id == "ESPIRS_ACT_AS_NATIONAL_ADMINISTRATOR" &&
                                ($scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_MAHB" ||
                                    $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_NATIONAL_REPORTER" ||
                                    $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_READ_ONLY" ||
                                    $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_READ_ONLY_FOR_COUNTRY"))
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            if (id == "ESPIRS_READ_ONLY" &&
                                ($scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_MAHB" ||
                                    $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_NATIONAL_REPORTER" ||
                                    $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_NATIONAL_ADMINISTRATOR" ||
                                    $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_READ_ONLY_FOR_COUNTRY" ||
                                    $scope.Model.ProfileApplications[i].Rights[j].Right == "IMPORT_ESTABLISHMENT"))
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            if (id == "ESPIRS_READ_ONLY_FOR_COUNTRY" &&
                                ($scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_MAHB" ||
                                    $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_NATIONAL_REPORTER" ||
                                    $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_NATIONAL_ADMINISTRATOR" ||
                                    $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_READ_ONLY" ||
                                    $scope.Model.ProfileApplications[i].Rights[j].Right == "IMPORT_ESTABLISHMENT"))
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            if (id == "IMPORT_ESTABLISHMENT" &&
                                ($scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_NATIONAL_REPORTER" ||
                                    $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_READ_ONLY" ||
                                    $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_READ_ONLY_FOR_COUNTRY"))
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            if (id == "SUPER_ADMIN_MINERVA" &&
                                $scope.Model.ProfileApplications[i].Rights[j].Right == "MINERVA_ADMINISTRATOR")
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            if (id == "MINERVA_ADMINISTRATOR" &&
                                $scope.Model.ProfileApplications[i].Rights[j].Right == "SUPER_ADMIN_MINERVA")
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            /**************************** start AIDA ****************************/
                            if (id == "ESPIRS_ACT_AS_MAHB" &&
                                $scope.Model.ProfileApplications[i].Rights[j].Right == "AIDA_EVENT_EDIT_OWN")
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            if (id == "ESPIRS_ACT_AS_MAHB" &&
                                $scope.Model.ProfileApplications[i].Rights[j].Right == "AIDA_EVENT_VIEW_OWN")
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            if (id == "AIDA_EVENT_VIEW_OWN" &&
                                $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_MAHB")
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            if (id == "AIDA_EVENT_EDIT_OWN" &&
                                $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_MAHB")
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            if (id == "AIDA_EVENT_VIEW_OWN" &&
                                $scope.Model.ProfileApplications[i].Rights[j].Right == "AIDA_EVENT_VIEW_ALL")
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            if (id == "AIDA_EVENT_VIEW_ALL" &&
                                $scope.Model.ProfileApplications[i].Rights[j].Right == "AIDA_EVENT_VIEW_OWN")
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            if (id == "AIDA_EVENT_EDIT_OWN" &&
                                $scope.Model.ProfileApplications[i].Rights[j].Right == "AIDA_EVENT_EDIT_ALL")
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            if (id == "AIDA_EVENT_EDIT_ALL" &&
                                $scope.Model.ProfileApplications[i].Rights[j].Right == "AIDA_EVENT_EDIT_OWN")
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            /**************************** end AIDA ****************************/
                            /**************************** start EMARS ****************************/
                            if (id == "ESPIRS_ACT_AS_MAHB" &&
                                $scope.Model.ProfileApplications[i].Rights[j].Right == "EMARS_ACCIDENT_EDIT_OWN")
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            if (id == "ESPIRS_ACT_AS_MAHB" &&
                                $scope.Model.ProfileApplications[i].Rights[j].Right == "EMARS_ACCIDENT_VIEW_OWN")
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            if (id == "EMARS_ACCIDENT_VIEW_OWN" &&
                                $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_MAHB")
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            if (id == "EMARS_ACCIDENT_EDIT_OWN" &&
                                $scope.Model.ProfileApplications[i].Rights[j].Right == "ESPIRS_ACT_AS_MAHB")
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            if (id == "EMARS_ACCIDENT_VIEW_OWN" &&
                                $scope.Model.ProfileApplications[i].Rights[j].Right == "EMARS_ACCIDENT_VIEW_ALL")
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            if (id == "EMARS_ACCIDENT_VIEW_ALL" &&
                                $scope.Model.ProfileApplications[i].Rights[j].Right == "EMARS_ACCIDENT_VIEW_OWN")
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            if (id == "EMARS_ACCIDENT_EDIT_OWN" &&
                                $scope.Model.ProfileApplications[i].Rights[j].Right == "EMARS_ACCIDENT_EDIT_ALL")
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            if (id == "EMARS_ACCIDENT_EDIT_ALL" &&
                                $scope.Model.ProfileApplications[i].Rights[j].Right == "EMARS_ACCIDENT_EDIT_OWN")
                                $scope.Model.ProfileApplications[i].Rights[j].Selected = false;
                            /**************************** end EMARS ****************************/
                            if ($scope.Model.ProfileApplications[i].Rights[j].Selected
                                && $scope.Model.ProfileApplications[i].Rights[j].IsCountryRequired) {
                                $scope.requireCountryProfileList.splice(0, 0, $scope.Model.ProfileApplications[i].Rights[j].ShortName);
                            }
                        }
                }
            };
            $scope.selectProfile = function (id) {
                $scope.scanProfiles(id);
                $scope.wasChanged = true;
                $scope.safeApply();
            };
            $scope.deleteRole = function () {
                MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("UM_ROLE_DELETE_QUESTION"), MessagesModule.MessageBoxType.YESNO, "", function () {
                    controller.Delete("Role", $scope.Model.RoleId, function (data) {
                        if (data.Data) {
                            controller.RedirectToAction($scope.Language, 'admin', 'role', 'list');
                        }
                    });
                });
            };
            $scope.unlockUser = function (Id) {
                controller.CallPutAction("User", "ForceUnlock", Id, null, function (data) {
                    MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("MINERVA_SUCCESSFULLY_UNLOCKED"), MessagesModule.MessageBoxType.SUCCESS, "", null, null, function () {
                        controller.CallGetAction($scope.serviceName, "GetRoleUsers", $scope.Model.RoleId, function (data) {
                            $scope.Model.Users = data.Data;
                        });
                    });
                });
            };
            $scope.unlockAllUsers = function () {
                controller.CallPutAction("User", "ForceUnlockAll", null, null, function (data) {
                    MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("MINERVA_SUCCESSFULLY_UNLOCKED"), MessagesModule.MessageBoxType.SUCCESS, "", null, null, function () {
                        controller.CallGetAction($scope.serviceName, "GetRoleUsers", $scope.Model.RoleId, function (data) {
                            $scope.Model.Users = data.Data;
                        });
                    });
                }, null, null, true);
            };
            // Load base CRUD methods and properties
            //super($scope, $http, "Admin", "Role", true);
            // Load cache data
            _this.GetCache("translatedlanguages", function (data) { $scope.Languages = data.Data; /*$scope.RepAuthCountries = data.Data;*/ });
            return _this;
        }
        return AdminRoleController;
    }(BaseModule.CrudBaseController));
    AdminRoleModule.AdminRoleController = AdminRoleController;
})(AdminRoleModule || (AdminRoleModule = {}));
angular.module('minervaApp').controller("AdminRoleModule.AdminRoleController", ["$scope", "$http", AdminRoleModule.AdminRoleController]);
//AdminRoleController.js.map;
/*! AdminRoleListController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var AdminRoleModule;
(function (AdminRoleModule) {
    /**********************************   SEARCH/VIEW CONTROLLER ********************************************/
    var AdminRoleSearchController = /** @class */ (function (_super) {
        __extends(AdminRoleSearchController, _super);
        function AdminRoleSearchController($scope, $http, $timeout) {
            var _this = this;
            $scope.searchServiceName = "Role";
            _this = _super.call(this, $scope, $http, false) || this;
            var controller = _this;
            // Method called to search cms content
            $scope.search = function (pageNr) {
                if (pageNr === void 0) { pageNr = null; }
                if (pageNr == null || pageNr < 1)
                    pageNr = 1;
                // add searching parameter to query string
                var query = "";
                query = query + "currentPage=" + pageNr;
                query = query + "&rpp=" + $scope.RecordPerPage;
                query = query + "&sortby=" + $scope.sortSelectedItem;
                query = query + "&sortdir=" + $scope.sortDirection;
                controller.Search($scope.searchServiceName, query, function (data) {
                    var searchResult = data.Data;
                    $scope.paging.maxPages = searchResult.maxPages;
                    $scope.paging.currentPage = searchResult.currentPage;
                    $scope.paging.totlaResults = searchResult.totlaResults;
                    $scope.paging.GetSelectablePages();
                    $scope.results = searchResult.resultSet;
                });
            };
            // reset all search filters and call a new searh
            $scope.resetSearch = function () {
                $scope.paging.currentPage = 1;
                $scope.SearchingText = "";
                $scope.SelectedLanguage = null;
                $scope.search();
            };
            $scope.deleteRole = function (roleId) {
                MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("UM_ROLE_DELETE_QUESTION"), MessagesModule.MessageBoxType.YESNO, "", function () {
                    controller.Delete($scope.searchServiceName, roleId, function (data) {
                        if (data.Data) {
                            $scope.search($scope.paging.currentPage);
                            MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("UM_ROLE_DELETED"), MessagesModule.MessageBoxType.SUCCESS);
                        }
                        else {
                            MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("UM_ROLE_DELETE_ERROR"), MessagesModule.MessageBoxType.ERROR);
                        }
                    });
                });
            };
            $scope.unlock = function (Id) {
                controller.CallPutAction($scope.searchServiceName, "ForceUnlock", Id, null, function (data) {
                    MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("MINERVA_SUCCESSFULLY_UNLOCKED"), MessagesModule.MessageBoxType.SUCCESS, "", null, null, function () {
                        $scope.search($scope.paging.currentPage);
                    });
                });
            };
            $scope.unlockAll = function () {
                controller.CallPutAction($scope.searchServiceName, "ForceUnlockAll", null, null, function (data) {
                    MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("MINERVA_SUCCESSFULLY_UNLOCKED"), MessagesModule.MessageBoxType.SUCCESS, "", null, null, function () {
                        $scope.search($scope.paging.currentPage);
                    });
                }, null, null, true);
            };
            // Load cache data
            _this.GetCache("translatedlanguages", function (data) { $scope.Languages = data.Data; /*$scope.RepAuthCountries = data.Data;*/ });
            // launch first search
            $scope.search();
            return _this;
        }
        return AdminRoleSearchController;
    }(SearchModule.GenericSearchController));
    AdminRoleModule.AdminRoleSearchController = AdminRoleSearchController;
})(AdminRoleModule || (AdminRoleModule = {}));
angular.module('minervaApp').controller("AdminRoleModule.AdminRoleSearchController", ["$scope", "$http", AdminRoleModule.AdminRoleSearchController]);
//AdminRoleListController.js.map;
/*! AdminRssController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var AdminRssModule;
(function (AdminRssModule) {
    var AdminRssController = /** @class */ (function (_super) {
        __extends(AdminRssController, _super);
        function AdminRssController($scope, $http) {
            var _this = 
            // Load base CRUD methods and properties
            _super.call(this, $scope, $http, "Admin", "Rss", false) || this;
            var controller = _this;
            $scope.WorkingAreaId = "";
            var waId = controller.GetParameterByName('waId');
            if (waId != null && waId != '' && waId != 'undefined') {
                $scope.WorkingAreaId = waId;
                $scope.WorkingAreaQueryString = "waId=" + waId;
                $scope.AddModelQueryString = $scope.WorkingAreaQueryString;
                $scope.UpdateModelQueryString = $scope.WorkingAreaQueryString;
                $scope.UnlockModelQueryString = $scope.WorkingAreaQueryString;
                $scope.LockModelQueryString = $scope.WorkingAreaQueryString;
                $scope.GetModelQueryString = $scope.WorkingAreaQueryString;
            }
            $scope.PublishedOption = [];
            $scope.PublishedOption.push({ id: "-1", name: "All feeds" });
            $scope.PublishedOption.push({ id: "True", name: "Published feeds" });
            $scope.PublishedOption.push({ id: "False", name: "Non published feeds" });
            $scope.PublishedOption.push({ id: "none", name: "Unset feeds" });
            $scope.SelectPublished = "-1";
            $scope.serviceName = "rss";
            $scope.Model = new Module.VMAdminRole();
            $scope.HasTransactions = false;
            $scope.ShowDetailPartial = true;
            try {
                $scope.RecordPerPage = parseInt($("#rpp_def").val());
            }
            catch (e) {
            }
            $scope.paging = new PagingModule.PagingController();
            //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
            // * * * * * * * * * * * * * * * * * * * * *   Base class methods implementation  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
            //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
            // callback method called  after a lock
            $scope.lockModelCallBack = function () { };
            // mandatory callbacks
            $scope.beforeSaveCallBack = function () { };
            $scope.afterSaveCallBack = function (data) {
                $scope.Model = data;
                $scope.safeApply();
            };
            $scope.lockModelErrorCallBack = function () { };
            $scope.openDetail = function () { $scope.ShowDetailPartial = true; };
            $scope.openFeeds = function () { $scope.ShowDetailPartial = false; $scope.searchFeeds(); };
            // Implements check super mandatory cmsContent fields function
            $scope.checkMandatoryFields = function (successCallBack) {
                if ($scope.Model.Name == null) {
                    var errorMessage = controller.GetMessage("UM_MANDATORY_NOT_FILLED");
                    MessagesModule.MessagesController.prototype.ShowMessageBox(errorMessage, MessagesModule.MessageBoxType.ERROR);
                }
                else {
                    successCallBack();
                }
            };
            $scope.discardRssChanges = function (area, controllerName, action, id, queryString) {
                if (action === void 0) { action = null; }
                if (id === void 0) { id = null; }
                if (queryString === void 0) { queryString = null; }
                var url = controller.CreateUrl($scope.Language, area, controllerName, action, id, queryString);
                if ($scope.wasChanged) {
                    MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("MINERVA_DISCARD_QUESTION"), MessagesModule.MessageBoxType.YESNO, "", function () {
                        if (id == null)
                            id = $scope.IdModel;
                        $scope.forceExit = true;
                        controller.RedirectToUrl(url);
                    });
                }
                else {
                    $scope.forceExit = true;
                    controller.RedirectToUrl(url);
                }
            };
            // callback method called after a new establishment save, to redirect the page in the edit mode
            $scope.addModelCallBack = function (data) {
                controller.RedirectToAction($scope.Language, 'admin', 'rss', 'edit', data.FeedId, $scope.WorkingAreaQueryString);
            };
            $scope.clearsearchFeeds = function () {
                $scope.SearchingText = "";
                $scope.SelectPublished = "-1";
                $scope.safeApply();
                $scope.searchFeeds(0);
            };
            // Method called to search cms content
            $scope.searchFeeds = function (pageNr) {
                if (pageNr === void 0) { pageNr = null; }
                if (pageNr == null || pageNr < 1)
                    pageNr = 1;
                // add searching parameter to query string
                var query = "";
                query = query + "waId=" + $scope.WorkingAreaId;
                query = query + "&feedId=" + $scope.Model.FeedId;
                query = query + "&searchingtext=" + ($scope.SearchingText != undefined ? encodeURIComponent($scope.SearchingText) : '');
                query = query + "&published=" + $scope.SelectPublished;
                query = query + "&language=" + ($scope.SelectedLanguage != undefined ? $scope.SelectedLanguage : '');
                query = query + "&currentPage=" + pageNr;
                query = query + "&rpp=" + $scope.RecordPerPage;
                controller.Search("Rss", query, function (data) {
                    var searchResult = data.Data;
                    $scope.paging.maxPages = searchResult.maxPages;
                    $scope.paging.currentPage = searchResult.currentPage;
                    $scope.paging.totlaResults = searchResult.totlaResults;
                    $scope.paging.GetSelectablePages();
                    $scope.feeds = searchResult.resultSet;
                });
            };
            // get the user and add it to the  list
            $scope.addFeedSource = function () {
                if ($scope.selectedFeedUrl == undefined || $scope.selectedFeedUrl == "")
                    return null;
                var exist = false;
                var i = 0;
                if ($scope.Model.Sources == null)
                    $scope.Model.Sources = [];
                for (i = 0; i < $scope.Model.Sources.length; i++) {
                    if ($scope.Model.Sources[i] == $scope.selectedFeedUrl) {
                        exist = true;
                        break;
                    }
                }
                if (!exist) {
                    var source = new Module.Admin.Rss.VMFeedSource();
                    source.Link = $scope.selectedFeedUrl.text;
                    $scope.Model.Sources.push(source);
                    $scope.selectedFeedUrl = '';
                }
            };
            $scope.removeFeedSource = function (idx) {
                $scope.Model.Sources.splice(idx, 1);
                $scope.wasChanged = true;
                $scope.safeApply();
            };
            // remove the user to the list
            $scope.removeCompleteFeedSource = function (idx) {
                MessagesModule.MessagesController.prototype.ShowMessageBox("Are you sure to delete the source? All feed will be removed", MessagesModule.MessageBoxType.YESNO, "", function () {
                    controller.CallPutAction($scope.serviceName, "removeFeedSource", $scope.Model.FeedId, null, function (data) {
                        if ($scope.Model == null
                            || $scope.Model.Sources == null || $scope.Model.Sources.length < 1)
                            return;
                        $scope.Model.Sources.splice(idx, 1);
                        $scope.wasChanged = true;
                        $scope.safeApply();
                    }, null, "feedSourceId=" + $scope.Model.Sources[idx].FeedSourceId + "&" + $scope.WorkingAreaQueryString);
                });
            };
            $scope.refreshFeedSource = function (idx) {
                controller.CallPutAction($scope.serviceName, "refreshFeedSource", $scope.Model.FeedId, null, null, null, "feedSourceId=" + $scope.Model.Sources[idx].FeedSourceId + "&" + $scope.WorkingAreaQueryString);
            };
            $scope.deleteRss = function () {
                MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("UM_ROLE_DELETE_QUESTION"), MessagesModule.MessageBoxType.YESNO, "", function () {
                    controller.Delete("Role", $scope.Model.RoleId, function (data) {
                        if (data.Data) {
                            controller.RedirectToAction($scope.Language, 'admin', 'role', 'list');
                        }
                    });
                });
            };
            $scope.updateAlternativeUrl = function () {
                if ($scope.Model == null || $scope.IsNew)
                    return;
                MessagesModule.MessagesController.prototype.ShowMessageBox("Are you sure to update the alternative URL?", MessagesModule.MessageBoxType.YESNO, "", function () {
                    controller.CallPutAction($scope.serviceName, "UpdateAlternativeUrl", $scope.Model.FeedId, $scope.Model, function (data) {
                        MessagesModule.MessagesController.prototype.ShowMessageBox("Success!", MessagesModule.MessageBoxType.SUCCESS, "Alternative Url successfully updated!");
                        $scope.Model.Link = data.Data;
                        $scope.safeApply();
                    }, null, $scope.WorkingAreaQueryString);
                });
            };
            $scope.publishFeedItem = function (feedItemId) {
                controller.CallPostAction($scope.serviceName, "publishFeedItem", feedItemId, null, function (data) {
                    $scope.searchFeeds($scope.paging.currentPage);
                }, null, $scope.WorkingAreaQueryString);
                return true;
            };
            $scope.unpublishFeedItem = function (feedItemId) {
                controller.CallPostAction($scope.serviceName, "unpublishFeedItem", feedItemId, null, function (data) {
                    $scope.searchFeeds($scope.paging.currentPage);
                }, null, $scope.WorkingAreaQueryString);
                return true;
            };
            $scope.getNewRssFeedInstance = function () {
                controller.CallGetAction($scope.serviceName, "NewObjectInstance", null, function (data) {
                    $scope.Model = data.Data;
                }, null, $scope.WorkingAreaQueryString);
                return true;
            };
            $scope.loadPage = function () {
                $scope.IsNew = ($scope.urlVars[5] == undefined || $scope.urlVars[5] == null || $scope.urlVars[5] == '');
                $scope.IsEdit = !$scope.IsNew;
                if ($scope.IsEdit) {
                    $scope.IdModel = $scope.urlVars[5];
                    $scope.getModel($scope.IdModel);
                }
                else {
                    $scope.getNewRssFeedInstance();
                }
            };
            // Load base CRUD methods and properties
            //super($scope, $http, "Admin", "Rss", false);
            $scope.loadPage();
            return _this;
        }
        return AdminRssController;
    }(BaseModule.CrudBaseController));
    AdminRssModule.AdminRssController = AdminRssController;
})(AdminRssModule || (AdminRssModule = {}));
angular.module('minervaApp').controller("AdminRssModule.AdminRssController", ["$scope", "$http", AdminRssModule.AdminRssController]);
//AdminRssController.js.map;
/*! AdminRssSearchController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var AdminRssModule;
(function (AdminRssModule) {
    /**********************************   SEARCH/VIEW CONTROLLER ********************************************/
    var AdminRssSearchController = /** @class */ (function (_super) {
        __extends(AdminRssSearchController, _super);
        function AdminRssSearchController($scope, $http, $timeout) {
            var _this = this;
            $scope.searchServiceName = "Rss";
            _this = _super.call(this, $scope, $http, false) || this;
            var controller = _this;
            $scope.WorkingAreaId = "";
            var waId = controller.GetParameterByName('waId');
            if (waId != null && waId != '' && waId != 'undefined') {
                $scope.WorkingAreaId = waId;
                $scope.WorkingAreaQueryString = "?waId=" + waId;
            }
            // Method called to search cms content
            $scope.list = function (pageNr) {
                if (pageNr === void 0) { pageNr = null; }
                if (pageNr == null || pageNr < 1)
                    pageNr = 1;
                // add searching parameter to query string
                var query = "";
                query = query + "waId=" + $scope.WorkingAreaId;
                query = query + "&currentPage=" + pageNr;
                query = query + "&rpp=" + $scope.RecordPerPage;
                query = query + "&sortby=" + $scope.sortSelectedItem;
                query = query + "&sortdir=" + $scope.sortDirection;
                controller.List($scope.searchServiceName, function (data) {
                    var searchResult = data.Data;
                    $scope.paging.maxPages = searchResult.maxPages;
                    $scope.paging.currentPage = searchResult.currentPage;
                    $scope.paging.totlaResults = searchResult.totlaResults;
                    $scope.paging.GetSelectablePages();
                    $scope.results = searchResult.resultSet;
                }, null, true, query);
            };
            // reset all search filters and call a new searh
            $scope.resetSearch = function () {
                $scope.paging.currentPage = 1;
                $scope.SearchingText = "";
                $scope.search();
            };
            $scope.deleteFeed = function (feedId) {
                MessagesModule.MessagesController.prototype.ShowMessageBox("Are you sure to delete the current feed", MessagesModule.MessageBoxType.YESNO, "", function () {
                    controller.Delete($scope.searchServiceName, feedId, function (data) {
                        $scope.list($scope.paging.currentPage);
                    }, null, $scope.WorkingAreaQueryString);
                });
            };
            $scope.publishUnpublishFeed = function (feedId) {
                controller.CallPostAction($scope.searchServiceName, "PublishUnpublishFeed", feedId, null, function (data) {
                    $scope.list($scope.paging.currentPage);
                }, null, $scope.WorkingAreaQueryString);
                return true;
            };
            // launch first search
            $scope.list();
            return _this;
        }
        return AdminRssSearchController;
    }(SearchModule.GenericSearchController));
    AdminRssModule.AdminRssSearchController = AdminRssSearchController;
})(AdminRssModule || (AdminRssModule = {}));
angular.module('minervaApp').controller("AdminRssModule.AdminRssSearchController", ["$scope", "$http", AdminRssModule.AdminRssSearchController]);
//AdminRssSearchController.js.map;
/*! AdminUserController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
/* <reference path='../../../tsmodel/Admin/VMWorkingAreaComplete.ts' /> */
var AdminUserModule;
(function (AdminUserModule) {
    var AdminUserController = /** @class */ (function (_super) {
        __extends(AdminUserController, _super);
        function AdminUserController($scope, $http) {
            var _this = 
            // Initialize base class
            _super.call(this, $scope, $http, "Admin", "User", true) || this;
            var controller = _this;
            $scope.Model = null;
            $scope.SelectedLanguage = "EN";
            $scope.HasTransactions = false;
            try {
                $scope.RecordPerPage = parseInt($("#rpp_def").val());
            }
            catch (e) {
            }
            $scope.paging = new PagingModule.PagingController();
            // get user role
            $scope.getRole = function (firstCall) {
                if (firstCall === void 0) { firstCall = false; }
                var roleId = null;
                if ($scope.Model != null && $scope.Model.Role != null)
                    roleId = $scope.Model.Role.RoleId;
                controller.CallGetAction("Role", "GetRoleForUser", null, function (data) {
                    $scope.SelectedRole = data.Data;
                    if (!firstCall) {
                        $scope.wasChanged = true;
                    }
                    if (roleId != null) {
                        $scope.Model.MinervaRights = [];
                        for (var i = 0; i < $scope.SelectedRole.ProfileApplications.length; i++) {
                            for (var j = 0; j < $scope.SelectedRole.ProfileApplications[i].Rights.length; j++) {
                                var right = $scope.SelectedRole.ProfileApplications[i].Rights[j];
                                if (right.Selected) {
                                    var obj = new Module.VMWorkingAreaRight();
                                    obj.RightId = right.RightId;
                                    obj.RightName = right.Right;
                                    $scope.Model.MinervaRights.push(obj);
                                }
                            }
                        }
                    }
                    $scope.safeApply();
                    $scope.setProfiles();
                }, null, (roleId != null) ? "rid=" + roleId : null);
            };
            //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
            // * * * * * * * * * * * * * * * * * * * * *   Base class methods implementation  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
            //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
            // Implements check super mandatory cmsContent fields function
            $scope.checkMandatoryFields = function (successCallBack) {
                if ($scope.Model != null && $scope.Model.Username == null) {
                    var errorMessage = controller.GetMessage("UM_MANDATORY_NOT_FILLED");
                    MessagesModule.MessagesController.prototype.ShowMessageBox(errorMessage, MessagesModule.MessageBoxType.ERROR);
                }
                else {
                    successCallBack();
                }
            };
            // callback method called after a new establishment save, to redirect the page in the edit mode
            $scope.addModelCallBack = function (data) {
                controller.RedirectToAction($scope.Language, 'admin', 'user', 'edit', data.UserId);
            };
            // callback method called  after a lock
            $scope.lockModelCallBack = function (model) {
                if ($scope.Model == null)
                    return;
                $scope.getRole(false);
            };
            // mandatory callbacks
            $scope.beforeSaveCallBack = function () {
                $scope.Model.EMail = $scope.Model.UserName;
                if ($scope.Model != null && $scope.SelectedRole != null && !$scope.isCountryRequired())
                    $scope.Model.Countries = null;
            };
            $scope.afterSaveCallBack = function () { };
            $scope.lockModelErrorCallBack = function () {
                window.history.back();
            };
            // remove the user from the list
            $scope.removeUser = function (id) {
                if ($scope.SelectedUser == null || $scope.Model == null
                    || $scope.Model.Users == null || $scope.Model.Users.length < 1)
                    return;
                var i = 0;
                var index = 0;
                for (i = 0; i < $scope.Model.Users.length; i++) {
                    if ($scope.Model.Users[i].UserId == id) {
                        index = i;
                        break;
                    }
                }
                $scope.Model.Users.splice(index, 1);
                $scope.wasChanged = true;
                $scope.safeApply();
            };
            //Task 1973:Remove user - Remove user after 2 month of inactivity
            // Remove user : Click on button RemoveUser
            $scope.remove_user = function () {
                var message = controller.GetMessage("UM_REMOVE_USER_QUESTION");
                MessagesModule.MessagesController.prototype.ShowMessageBox(message, MessagesModule.MessageBoxType.YESNO, "", function () {
                    controller.Delete($scope.serviceName, $scope.Model.UserId, function (data) {
                        message = controller.GetMessage("UM_SUCCESSFULLY_REMOVED");
                        MessagesModule.MessagesController.prototype.ShowMessageBox(message, MessagesModule.MessageBoxType.SUCCESS, "", null, null, function () {
                            controller.RedirectToAction($scope.Language, 'admin', 'user', 'search');
                        });
                    });
                });
            };
            $scope.setParticipant = function (wid, rid, rname, partecipantid, partecipantname, checked) {
                var right = new Module.VMAdminRight();
                right.RightId = rid;
                right.Right = rname;
                right.Selected = checked;
                $scope.selectProfile(wid, right, partecipantid, partecipantname);
            };
            // confirm the select profile operation
            $scope.selectProfile = function (wid, right, partecipantid, partecipantname) {
                var add = true;
                if ($scope.Model == null)
                    return;
                $scope.wasChanged = true;
                if (wid == null)
                    $scope.Model.Role = null;
                if ($scope.Model.WorkingAreaRights == null)
                    $scope.Model.WorkingAreaRights = [];
                if ($scope.Model.MinervaRights == null)
                    $scope.Model.MinervaRights = [];
                if (right.Selected) {
                    var obj = new Module.VMWorkingAreaRight();
                    obj.RightId = right.RightId;
                    obj.RightName = right.Right;
                    obj.WorkingAreaId = wid;
                    if (wid == null) {
                        //solo uno tra NR/NA e MAHB può essere selezionato
                        for (var i = 0; i < $scope.Model.MinervaRights.length; i++) {
                            if (right.Right == "ESPIRS_ACT_AS_MAHB" &&
                                ($scope.Model.MinervaRights[i].RightName == "ESPIRS_ACT_AS_NATIONAL_ADMINISTRATOR" ||
                                    $scope.Model.MinervaRights[i].RightName == "ESPIRS_ACT_AS_NATIONAL_REPORTER" ||
                                    $scope.Model.MinervaRights[i].RightName == "ESPIRS_READ_ONLY" ||
                                    $scope.Model.MinervaRights[i].RightName == "ESPIRS_READ_ONLY_FOR_COUNTRY" ||
                                    $scope.Model.MinervaRights[i].RightName == "IMPORT_ESTABLISHMENT" ||
                                    $scope.Model.MinervaRights[i].RightName == "AIDA_EVENT_EDIT_OWN" ||
                                    $scope.Model.MinervaRights[i].RightName == "AIDA_EVENT_VIEW_OWN" ||
                                    $scope.Model.MinervaRights[i].RightName == "EMARS_ACCIDENT_EDIT_OWN" ||
                                    $scope.Model.MinervaRights[i].RightName == "EMARS_ACCIDENT_VIEW_OWN")) {
                                $scope.Model.MinervaRights.splice(i, 1);
                                continue;
                            }
                            if (right.Right == "ESPIRS_ACT_AS_NATIONAL_REPORTER" &&
                                ($scope.Model.MinervaRights[i].RightName == "ESPIRS_ACT_AS_MAHB" ||
                                    $scope.Model.MinervaRights[i].RightName == "ESPIRS_ACT_AS_NATIONAL_ADMINISTRATOR" ||
                                    $scope.Model.MinervaRights[i].RightName == "ESPIRS_READ_ONLY" ||
                                    $scope.Model.MinervaRights[i].RightName == "ESPIRS_READ_ONLY_FOR_COUNTRY" ||
                                    $scope.Model.MinervaRights[i].RightName == "IMPORT_ESTABLISHMENT" ||
                                    $scope.Model.MinervaRights[i].RightName == "AIDA_EVENT_EDIT_ALL" ||
                                    $scope.Model.MinervaRights[i].RightName == "AIDA_EVENT_VIEW_ALL" ||
                                    $scope.Model.MinervaRights[i].RightName == "EMARS_ACCIDENT_EDIT_ALL" ||
                                    $scope.Model.MinervaRights[i].RightName == "EMARS_ACCIDENT_VIEW_ALL")) {
                                $scope.Model.MinervaRights.splice(i, 1);
                                continue;
                            }
                            if (right.Right == "ESPIRS_ACT_AS_NATIONAL_ADMINISTRATOR" &&
                                ($scope.Model.MinervaRights[i].RightName == "ESPIRS_ACT_AS_MAHB" ||
                                    $scope.Model.MinervaRights[i].RightName == "ESPIRS_ACT_AS_NATIONAL_REPORTER" ||
                                    $scope.Model.MinervaRights[i].RightName == "ESPIRS_READ_ONLY" ||
                                    $scope.Model.MinervaRights[i].RightName == "ESPIRS_READ_ONLY_FOR_COUNTRY" ||
                                    $scope.Model.MinervaRights[i].RightName == "AIDA_EVENT_EDIT_ALL" ||
                                    $scope.Model.MinervaRights[i].RightName == "AIDA_EVENT_VIEW_ALL" ||
                                    $scope.Model.MinervaRights[i].RightName == "EMARS_ACCIDENT_EDIT_ALL" ||
                                    $scope.Model.MinervaRights[i].RightName == "EMARS_ACCIDENT_VIEW_ALL")) {
                                $scope.Model.MinervaRights.splice(i, 1);
                                continue;
                            }
                            if (right.Right == "ESPIRS_READ_ONLY" &&
                                ($scope.Model.MinervaRights[i].RightName == "ESPIRS_ACT_AS_MAHB" ||
                                    $scope.Model.MinervaRights[i].RightName == "ESPIRS_ACT_AS_NATIONAL_REPORTER" ||
                                    $scope.Model.MinervaRights[i].RightName == "ESPIRS_ACT_AS_NATIONAL_ADMINISTRATOR" ||
                                    $scope.Model.MinervaRights[i].RightName == "ESPIRS_READ_ONLY_FOR_COUNTRY" ||
                                    $scope.Model.MinervaRights[i].RightName == "IMPORT_ESTABLISHMENT")) {
                                $scope.Model.MinervaRights.splice(i, 1);
                                continue;
                            }
                            if (right.Right == "ESPIRS_READ_ONLY_FOR_COUNTRY" &&
                                ($scope.Model.MinervaRights[i].RightName == "ESPIRS_ACT_AS_MAHB" ||
                                    $scope.Model.MinervaRights[i].RightName == "ESPIRS_ACT_AS_NATIONAL_REPORTER" ||
                                    $scope.Model.MinervaRights[i].RightName == "ESPIRS_ACT_AS_NATIONAL_ADMINISTRATOR" ||
                                    $scope.Model.MinervaRights[i].RightName == "ESPIRS_READ_ONLY" ||
                                    $scope.Model.MinervaRights[i].RightName == "IMPORT_ESTABLISHMENT" ||
                                    $scope.Model.MinervaRights[i].RightName == "AIDA_EVENT_EDIT_ALL" ||
                                    $scope.Model.MinervaRights[i].RightName == "AIDA_EVENT_VIEW_ALL" ||
                                    $scope.Model.MinervaRights[i].RightName == "EMARS_ACCIDENT_EDIT_ALL" ||
                                    $scope.Model.MinervaRights[i].RightName == "EMARS_ACCIDENT_VIEW_ALL")) {
                                $scope.Model.MinervaRights.splice(i, 1);
                                continue;
                            }
                            if (right.Right == "IMPORT_ESTABLISHMENT" &&
                                ($scope.Model.MinervaRights[i].RightName == "ESPIRS_ACT_AS_NATIONAL_REPORTER" ||
                                    $scope.Model.MinervaRights[i].RightName == "ESPIRS_READ_ONLY" ||
                                    $scope.Model.MinervaRights[i].RightName == "ESPIRS_READ_ONLY_FOR_COUNTRY")) {
                                $scope.Model.MinervaRights.splice(i, 1);
                                continue;
                            }
                            if (right.Right == "SUPER_ADMIN_MINERVA" &&
                                $scope.Model.MinervaRights[i].RightName == "MINERVA_ADMINISTRATOR") {
                                $scope.Model.MinervaRights.splice(i, 1);
                                continue;
                            }
                            if (right.Right == "MINERVA_ADMINISTRATOR" &&
                                $scope.Model.MinervaRights[i].RightName == "SUPER_ADMIN_MINERVA") {
                                $scope.Model.MinervaRights.splice(i, 1);
                                continue;
                            }
                            /**************************** start AIDA ****************************/
                            if ((right.Right == "AIDA_EVENT_VIEW_OWN" || right.Right == "AIDA_EVENT_EDIT_OWN") && ($scope.Model.MinervaRights[i].RightName == "ESPIRS_ACT_AS_MAHB" ||
                                $scope.Model.MinervaRights[i].RightName == "AIDA_EVENT_EDIT_ALL" ||
                                $scope.Model.MinervaRights[i].RightName == "AIDA_EVENT_EDIT_ALL" ||
                                $scope.Model.MinervaRights[i].RightName == "EMARS_ACCIDENT_EDIT_ALL" ||
                                $scope.Model.MinervaRights[i].RightName == "EMARS_ACCIDENT_VIEW_ALL")) {
                                $scope.Model.MinervaRights.splice(i, 1);
                                continue;
                            }
                            if ((right.Right == "AIDA_EVENT_VIEW_ALL" || right.Right == "AIDA_EVENT_EDIT_ALL") && ($scope.Model.MinervaRights[i].RightName == "AIDA_EVENT_EDIT_OWN" ||
                                $scope.Model.MinervaRights[i].RightName == "AIDA_EVENT_VIEW_OWN" ||
                                $scope.Model.MinervaRights[i].RightName == "EMARS_ACCIDENT_EDIT_OWN" ||
                                $scope.Model.MinervaRights[i].RightName == "EMARS_ACCIDENT_VIEW_OWN" ||
                                $scope.Model.MinervaRights[i].RightName == "ESPIRS_ACT_AS_NATIONAL_ADMINISTRATOR" ||
                                $scope.Model.MinervaRights[i].RightName == "ESPIRS_ACT_AS_NATIONAL_REPORTER" ||
                                $scope.Model.MinervaRights[i].RightName == "ESPIRS_READ_ONLY_FOR_COUNTRY")) {
                                $scope.Model.MinervaRights.splice(i, 1);
                                continue;
                            }
                            /**************************** end AIDA ****************************/
                            /**************************** start EMARS ****************************/
                            if ((right.Right == "EMARS_ACT_AS_NATIONAL_ADMINISTRATOR"
                                || right.Right == "EMARS_ACT_AS_NATIONAL_REPORTER"
                                || right.Right == "EMARS_ACT_AS_POWERUSER"
                                || right.Right == "EMARS_ACT_AS_NATIONAL_POWERUSER") && ($scope.Model.MinervaRights[i].RightName == "EMARS_ACT_AS_MAHB")) {
                                $scope.Model.MinervaRights.splice(i, 1);
                                continue;
                            }
                            if ((right.Right == "EMARS_ACT_AS_MAHB"
                                || right.Right == "EMARS_ACT_AS_NATIONAL_ADMINISTRATOR"
                                || right.Right == "EMARS_ACT_AS_POWERUSER"
                                || right.Right == "EMARS_ACT_AS_NATIONAL_POWERUSER") && ($scope.Model.MinervaRights[i].RightName == "EMARS_ACT_AS_NATIONAL_REPORTER")) {
                                $scope.Model.MinervaRights.splice(i, 1);
                                continue;
                            }
                            if ((right.Right == "EMARS_ACT_AS_NATIONAL_REPORTER"
                                || right.Right == "EMARS_ACT_AS_POWERUSER"
                                || right.Right == "EMARS_ACT_AS_NATIONAL_POWERUSER"
                                || right.Right == "EMARS_ACT_AS_MAHB") && ($scope.Model.MinervaRights[i].RightName == "EMARS_ACT_AS_NATIONAL_ADMINISTRATOR")) {
                                $scope.Model.MinervaRights.splice(i, 1);
                                continue;
                            }
                            if ((right.Right == "EMARS_ACT_AS_NATIONAL_REPORTER"
                                || right.Right == "EMARS_ACT_AS_NATIONAL_ADMINISTRATOR"
                                || right.Right == "EMARS_ACT_AS_NATIONAL_POWERUSER"
                                || right.Right == "EMARS_ACT_AS_MAHB") && ($scope.Model.MinervaRights[i].RightName == "EMARS_ACT_AS_POWERUSER")) {
                                $scope.Model.MinervaRights.splice(i, 1);
                                continue;
                            }
                            if ((right.Right == "EMARS_ACT_AS_NATIONAL_REPORTER"
                                || right.Right == "EMARS_ACT_AS_POWERUSER"
                                || right.Right == "EMARS_ACT_AS_NATIONAL_ADMINISTRATOR"
                                || right.Right == "EMARS_ACT_AS_MAHB") && ($scope.Model.MinervaRights[i].RightName == "EMARS_ACT_AS_NATIONAL_POWERUSER")) {
                                $scope.Model.MinervaRights.splice(i, 1);
                                continue;
                            }
                            /**************************** end EMARS ****************************/
                        }
                        $scope.Model.MinervaRights.push(obj);
                    }
                    else {
                        //se non esiste il profilo partecipante lo aggiungo
                        $scope.Model.WorkingAreaRights.push(obj);
                        var exist = false;
                        for (var i = 0; i < $scope.Model.WorkingAreaRights.length; i++) {
                            if ($scope.Model.WorkingAreaRights[i].WorkingAreaId == wid && $scope.Model.WorkingAreaRights[i].RightId == partecipantid)
                                exist = true;
                        }
                        if (!exist) {
                            var obj = new Module.VMWorkingAreaRight();
                            obj.RightId = partecipantid;
                            obj.RightName = partecipantname;
                            obj.WorkingAreaId = wid;
                            $scope.Model.WorkingAreaRights.push(obj);
                        }
                    }
                }
                else {
                    //sto eliminando qualcosa
                    if (wid == null) {
                        for (var i = 0; i < $scope.Model.MinervaRights.length; i++) {
                            if ($scope.Model.MinervaRights[i].RightId == right.RightId)
                                $scope.Model.MinervaRights.splice(i, 1);
                        }
                    }
                    else {
                        for (var i = 0; i < $scope.Model.WorkingAreaRights.length; i++)
                            if ($scope.Model.WorkingAreaRights[i].RightId == right.RightId &&
                                $scope.Model.WorkingAreaRights[i].WorkingAreaId == wid)
                                $scope.Model.WorkingAreaRights.splice(i, 1);
                        //se ho deselezionazionato partecipante deseleziono TUTTI quelli della WA
                        if (partecipantid == right.RightId)
                            for (var i = $scope.Model.WorkingAreaRights.length - 1; i >= 0; i--) {
                                if ($scope.Model.WorkingAreaRights[i].WorkingAreaId == wid)
                                    $scope.Model.WorkingAreaRights.splice(i, 1);
                            }
                    }
                }
                $scope.setProfiles();
                $scope.safeApply();
            };
            // check all mandatory fields
            $scope.checkMandatoryFields = function (successCallBack) {
                if ($scope.Model == null)
                    return;
                if ($scope.isCountryRequired() && ($scope.Model.Countries == null || $scope.Model.Countries.CountryId == '')) {
                    // show message
                    var errorMessage = controller.GetMessage("UM_MANDATORY_COUNTRY");
                    MessagesModule.MessagesController.prototype.ShowMessageBox(errorMessage, MessagesModule.MessageBoxType.ERROR);
                }
                else {
                    successCallBack();
                }
            };
            $scope.setProfiles = function () {
                //reset
                if ($scope.SelectedRole != null && $scope.SelectedRole.ProfileApplications != null)
                    for (var k = 0; k < $scope.SelectedRole.ProfileApplications.length; k++) {
                        for (var j = 0; j < $scope.SelectedRole.ProfileApplications[k].Rights.length; j++) {
                            $scope.SelectedRole.ProfileApplications[k].Rights[j].Selected = false;
                        }
                    }
                if ($scope.Model != null && $scope.Model.MinervaRights != null && $scope.SelectedRole != null && $scope.SelectedRole.ProfileApplications != null)
                    for (var i = 0; i < $scope.Model.MinervaRights.length; i++) {
                        var rid = $scope.Model.MinervaRights[i].RightId;
                        for (var k = 0; k < $scope.SelectedRole.ProfileApplications.length; k++) {
                            for (var j = 0; j < $scope.SelectedRole.ProfileApplications[k].Rights.length; j++) {
                                if ($scope.SelectedRole.ProfileApplications[k].Rights[j].RightId == rid)
                                    $scope.SelectedRole.ProfileApplications[k].Rights[j].Selected = true;
                            }
                        }
                    }
                if ($scope.WorkingAreas != null)
                    for (var k = 0; k < $scope.WorkingAreas.length; k++) {
                        $scope.WorkingAreas[k].isAdmin = false;
                        $scope.WorkingAreas[k].isParticipant = false;
                        if ($scope.WorkingAreas[k].Tools != null)
                            for (var j = 0; j < $scope.WorkingAreas[k].Tools.length; j++)
                                if ($scope.WorkingAreas[k].Tools[j].Rights != null)
                                    for (var l = 0; l < $scope.WorkingAreas[k].Tools[j].Rights.length; l++)
                                        $scope.WorkingAreas[k].Tools[j].Rights[l].Selected = false;
                    }
                if ($scope.Model != null && $scope.Model.WorkingAreaRights != null && $scope.WorkingAreas != null) {
                    for (var i = 0; i < $scope.Model.WorkingAreaRights.length; i++) {
                        var rid = $scope.Model.WorkingAreaRights[i].RightId;
                        var wid = $scope.Model.WorkingAreaRights[i].WorkingAreaId;
                        ///qui
                        for (var k = 0; k < $scope.WorkingAreas.length; k++) {
                            var twid = $scope.WorkingAreas[k].WorkingAreaId;
                            if ($scope.Model.WorkingAreaRights[i].RightName == "WA_ADMIN" && wid == twid) {
                                $scope.WorkingAreas[k].isAdmin = true;
                            }
                            if ($scope.WorkingAreas[k].Tools != null) {
                                if (twid == wid)
                                    $scope.WorkingAreas[k].isParticipant = true;
                                for (var j = 0; j < $scope.WorkingAreas[k].Tools.length; j++) {
                                    if ($scope.WorkingAreas[k].Tools[j].Rights != null) {
                                        for (var l = 0; l < $scope.WorkingAreas[k].Tools[j].Rights.length; l++) {
                                            if ($scope.WorkingAreas[k].Tools[j].Rights[l].RightId == rid && twid == wid) {
                                                $scope.WorkingAreas[k].isParticipant = true;
                                                $scope.WorkingAreas[k].Tools[j].Rights[l].Selected = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };
            $scope.isCountryRequired = function () {
                if ($scope.SelectedRole == null || $scope.SelectedRole.ProfileApplications == null)
                    return false;
                var i = 0;
                var j = 0;
                for (i = 0; i < $scope.SelectedRole.ProfileApplications.length; i++) {
                    for (j = 0; j < $scope.SelectedRole.ProfileApplications[i].Rights.length; j++) {
                        if ($scope.SelectedRole.ProfileApplications[i].Rights[j].Selected)
                            if ($scope.SelectedRole.ProfileApplications[i].Rights[j].IsCountryRequired)
                                return true;
                    }
                }
                return false;
            };
            //super($scope, $http, "Admin", "User", true);
            //     if ($scope.IdModel)
            //       controller.CallPutAction("User", "ForceUnlock", $scope.IdModel, null, function (data) { });
            $scope.doNotUnlockOnExit = true;
            // Load cache data
            _this.GetCache("USER_STATUSES", function (data) { $scope.Statuses = data.Data; });
            _this.GetCache("COUNTRIES", function (data) { $scope.Countries = data.Data; });
            _this.List("Role", function (data) { $scope.Roles = data.Data; });
            //$scope.getRole(true);
            _this.CallGetAction("WorkingArea", "GetAllComplete", null, function (data) { $scope.WorkingAreas = data.Data; $scope.setProfiles(); });
            return _this;
        }
        return AdminUserController;
    }(BaseModule.CrudBaseController));
    AdminUserModule.AdminUserController = AdminUserController;
})(AdminUserModule || (AdminUserModule = {}));
angular.module('minervaApp').controller("AdminUserModule.AdminUserController", ["$scope", "$http", AdminUserModule.AdminUserController]);
//AdminUserController.js.map;
/*! AdminUserListController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var AdminUserModule;
(function (AdminUserModule) {
    /**********************************   SEARCH/VIEW CONTROLLER ********************************************/
    var AdminUserSearchController = /** @class */ (function (_super) {
        __extends(AdminUserSearchController, _super);
        function AdminUserSearchController($scope, $http, $timeout) {
            var _this = this;
            $scope.searchServiceName = "User";
            $scope.sortSelectedItem = "LAST_ACC";
            _this = _super.call(this, $scope, $http, true) || this;
            var controller = _this;
            var nu = _this.GetParameterByName('nu');
            // Method called to search cms content
            $scope.search = function (pageNr) {
                if (pageNr === void 0) { pageNr = null; }
                if (pageNr == null || pageNr < 1)
                    pageNr = 1;
                // add searching parameter to query string
                var query = "";
                query = query + "searchingtext=" + ($scope.SearchingText != undefined ? encodeURIComponent($scope.SearchingText) : '');
                query = query + "&roleId=" + ($scope.SelectedRole != undefined ? encodeURIComponent($scope.SelectedRole) : '');
                query = query + "&statusId=" + ($scope.SelectedStatus != undefined ? encodeURIComponent($scope.SelectedStatus) : '');
                query = query + "&countryId=" + ($scope.Country != undefined ? encodeURIComponent($scope.Country) : '');
                query = query + "&workingAreaId=" + ($scope.WorkingArea != undefined ? encodeURIComponent($scope.WorkingArea) : '');
                query = query + "&currentPage=" + pageNr;
                query = query + "&rpp=" + $scope.RecordPerPage;
                query = query + "&sortby=" + ($scope.sortSelectedItem != undefined ? $scope.sortSelectedItem : '');
                query = query + "&sortdir=" + ($scope.sortDirection != undefined ? $scope.sortDirection : '');
                controller.Search($scope.searchServiceName, query, function (data) {
                    var searchResult = data.Data;
                    $scope.paging.maxPages = searchResult.maxPages;
                    $scope.paging.currentPage = searchResult.currentPage;
                    $scope.paging.totlaResults = searchResult.totlaResults;
                    $scope.paging.GetSelectablePages();
                    $scope.results = searchResult.resultSet;
                });
            };
            // reset all search filters and call a new searh
            $scope.resetSearch = function () {
                $scope.paging.currentPage = 1;
                $scope.SearchingText = "";
                $scope.SelectedStatus = null;
                $scope.SelectedRole = null;
                $scope.search();
            };
            // show if hidden or hide if showed, a html control and put the class selected to it
            $scope.showHideDiv = function (id, callerId) {
                if (callerId === void 0) { callerId = null; }
                if ($("#" + id).is(":hidden")) {
                    $("#" + id).show();
                    if (callerId != null) {
                        if (!$("#" + callerId).hasClass("selected")) {
                            $("#" + callerId).addClass("selected");
                        }
                    }
                }
                else {
                    $("#" + id).hide();
                    if (callerId != null) {
                        if ($("#" + callerId).hasClass("selected")) {
                            $("#" + callerId).removeClass("selected");
                        }
                    }
                }
            };
            // update the user status
            $scope.changeUserStatus = function (userId, statusId) {
                MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("UM_STATUS_UPDATE_QUESTION"), MessagesModule.MessageBoxType.YESNO, "", function () {
                    controller.CallPutAction($scope.searchServiceName, "UpdateUserStatus", userId, null, function (data) {
                        if (data.Data) {
                            MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("UM_STATUS_UPDATED"), MessagesModule.MessageBoxType.SUCCESS, "", null, null, function () {
                                $scope.search($scope.paging.currentPage);
                            });
                        }
                        else {
                            MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("UM_STATUS_UPDATE_ERROR"), MessagesModule.MessageBoxType.ERROR);
                        }
                    }, null, "statusId=" + statusId);
                }, function () {
                    $scope.search($scope.paging.currentPage);
                });
            };
            $scope.unlock = function (Id) {
                controller.CallPutAction($scope.searchServiceName, "ForceUnlock", Id, null, function (data) {
                    MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("MINERVA_SUCCESSFULLY_UNLOCKED"), MessagesModule.MessageBoxType.SUCCESS, "", null, null, function () {
                        $scope.search($scope.paging.currentPage);
                    });
                });
            };
            $scope.unlockAll = function () {
                controller.CallPutAction($scope.searchServiceName, "ForceUnlockAll", null, null, function (data) {
                    MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("MINERVA_SUCCESSFULLY_UNLOCKED"), MessagesModule.MessageBoxType.SUCCESS, "", null, null, function () {
                        $scope.search($scope.paging.currentPage);
                    });
                }, null, null, true);
            };
            // to activate the user redirect to the edit page
            $scope.activateUser = function (id) {
                controller.RedirectToAction(null, 'admin', 'user', 'edit', id);
            };
            // Load cache data
            _this.GetCache("ALL_USER_STATUSES", function (data) { $scope.AllStatuses = data.Data; });
            _this.GetCache("USER_STATUSES", function (data) { $scope.Statuses = data.Data; });
            _this.GetCache("countries", function (data) { $scope.Countries = data.Data; });
            _this.List("Role", function (data) { $scope.Roles = data.Data; });
            _this.CallGetAction("WorkingArea", "GetAll", null, function (data) { $scope.WorkingAreas = data.Data; });
            if (nu != null && nu != '') {
                $scope.SelectedStatus = "NOT_ACTIVATED";
            }
            // launch first search
            $scope.search();
            return _this;
        }
        return AdminUserSearchController;
    }(SearchModule.GenericSearchController));
    AdminUserModule.AdminUserSearchController = AdminUserSearchController;
})(AdminUserModule || (AdminUserModule = {}));
angular.module('minervaApp').controller("AdminUserModule.AdminUserSearchController", ["$scope", "$http", AdminUserModule.AdminUserSearchController]);
//AdminUserListController.js.map;
/*! CategoryController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var AdminCategoryModule;
(function (AdminCategoryModule) {
    var CategoryController = /** @class */ (function (_super) {
        __extends(CategoryController, _super);
        function CategoryController($scope, $http, $timeout) {
            var _this = _super.call(this, $scope, $http) || this;
            var controller = _this;
            $scope.IsNew = false;
            $scope.IsEdit = false;
            $scope.IsFirstLoad = true;
            $scope.showOverlay = false;
            $scope.serviceName = "Category";
            if ($scope.urlVars[5] != undefined && $scope.urlVars[5] != null && $scope.urlVars[5] != '' && $scope.IsFirstLoad)
                $scope.categoryId = $scope.urlVars[5];
            $scope.getCategoryTree = function () {
                // get menu id from url
                var queryString = '';
                if ($scope.categoryId != null && $scope.categoryId != '' && $scope.IsFirstLoad)
                    queryString = "mId=" + $scope.categoryId;
                var waId = controller.GetParameterByName('waId');
                $scope.WorkingAreaQueryString = "";
                var waId = controller.GetParameterByName('waId');
                if (waId != null && waId != '' && waId != 'undefined') {
                    $scope.WorkingAreaId = waId;
                    $scope.WorkingAreaQueryString = "&waId=" + waId;
                    if (queryString == '')
                        queryString = "waId=" + $scope.WorkingAreaId;
                    else
                        queryString = queryString + "&waId=" + $scope.WorkingAreaId;
                }
                $scope.IsLoading = true;
                controller.CallGetAction($scope.serviceName, "GetTree", null, function (data) {
                    $scope.RootModel = data.Data;
                    $scope.visit($scope.RootModel, function (item) {
                        if (item.icon == null)
                            item.icon = "/minerva/themes/minerva/images/icons/treemenu/icon_menu.png";
                        if (item.ParentId != null) {
                            item.expanded = false;
                        }
                        else {
                            item.expanded = true;
                        }
                    });
                    if ($scope.urlVars[5] != undefined && $scope.urlVars[5] != null && $scope.urlVars[5] != '')
                        $scope.editItem($scope.categoryId);
                    $scope.IsLoading = false;
                    $scope.IsFirstLoad = false;
                }, function () { $scope.IsLoading = false; }, queryString);
            };
            $scope.clearItem = function () {
                $scope.cancel();
                $scope.IsNew = false;
                $scope.IsEdit = true;
                $scope.IsLoading = true;
                $scope.Model = null;
            };
            $scope.editItem = function (id) {
                if (id != null) {
                    $scope.cancel();
                    $scope.IsNew = false;
                    $scope.IsEdit = true;
                    $scope.IsLoading = true;
                    if ($scope.newTranslation != null)
                        $scope.newTranslation.Title = "";
                    controller.CallPutAction($scope.serviceName, "Lock", id, null, function (data) {
                        $scope.Model = data.Data;
                        $scope.BackQueryString = "mId=" + $scope.Model.CategoryId;
                        $scope.showOverlay = false;
                        $scope.calculateAvailableLanguages();
                        /*  if ($scope.Model.LinkedParentWorkingArea != null && $scope.Model.LinkedParentWorkingArea.Id != null
                              && $scope.Model.LinkedParentWorkingArea.Id != '' && $scope.Model.LinkedParentWorkingArea.Id != 'undefined') {
                              $scope.WorkingAreaId = $scope.Model.LinkedParentWorkingArea.Id;
                              $scope.WorkingAreaQueryString = "&waId=" + $scope.Model.LinkedParentWorkingArea.Id;
                          }
                          else
                          {
                              $scope.WorkingAreaId = null;
                              $scope.WorkingAreaQueryString = "";
                          }
                           */
                    }, function () {
                        MessagesModule.MessagesController.prototype.ShowMessageBox("Do you want to unlock the menu?", MessagesModule.MessageBoxType.YESNO, "UNLOCK MENU", function () {
                            $scope.forceUnlockItem(id, function () { $scope.editItem(id); });
                        });
                    }, $scope.WorkingAreaQueryString);
                }
            };
            $scope.save = function (alternativecallback) {
                $scope.IsLoading = true;
                var i = 0;
                if ($scope.Model != null)
                    if ($scope.newTranslation != null)
                        $scope.newTranslation.Title = "";
                //$scope.calculateMenuProfiles();
                // if is new
                if ($scope.IsNew) {
                    controller.Post($scope.serviceName, $scope.Model, function (data) {
                        if (alternativecallback != null && alternativecallback != undefined) {
                            alternativecallback();
                            return;
                        }
                        $scope.Model = data.Data;
                        $scope.categoryId = $scope.Model.CategoryId;
                        $scope.BackQueryString = "mId=" + $scope.Model.CategoryId;
                        $scope.IsLoading = true;
                        $scope.showOverlay = true;
                        $scope.getCategoryTree();
                        $scope.IsLoading = false;
                        $scope.showOverlay = false;
                        $scope.IsEdit = true;
                        $scope.IsNew = false;
                        $scope.editItem($scope.Model.CategoryId);
                        //$scope.calculateAvailableLanguages();
                        //$scope.safeApply();
                    }, function () { $scope.IsLoading = false; });
                }
                else {
                    // if is a menu set the mime type to null
                    controller.Put($scope.serviceName, $scope.Model.CategoryId, $scope.Model, function (data) {
                        if (alternativecallback != null && alternativecallback != undefined) {
                            alternativecallback();
                            return;
                        }
                        $scope.Model = data.Data;
                        $scope.categoryId = $scope.Model.CategoryId;
                        $scope.BackQueryString = "mId=" + $scope.Model.CategoryId;
                        $scope.IsLoading = true;
                        $scope.showOverlay = true;
                        $scope.getCategoryTree();
                        $scope.IsLoading = false;
                        $scope.showOverlay = false;
                        $scope.IsEdit = true;
                        $scope.IsNew = false;
                        $scope.calculateAvailableLanguages();
                        $scope.safeApply();
                    }, function () { $scope.IsLoading = false; }, $scope.WorkingAreaQueryString);
                }
            };
            $scope.newItem = function (id) {
                controller.CallGetAction($scope.serviceName, "NewCategoryInstance", id, function (data) {
                    $scope.Model = data.Data;
                    $scope.categoryId = null;
                    $scope.BackQueryString = null;
                    $scope.safeApply(function () {
                        $scope.calculateAvailableLanguages();
                        $scope.cancel();
                        $scope.IsNew = true;
                        $scope.IsEdit = false;
                    });
                }, null, $scope.WorkingAreaQueryString);
            };
            $scope.removeItem = function (id) {
                /*var parentId:string = null;
                if ($scope.Model != null && $scope.Model != null) {
                    parentId = $scope.Model.ParentId;
                }*/
                var x = confirm(controller.GetMessage("CMS_FILESYSTEM_DELETE_CONFIRM"));
                if (x) {
                    $scope.IsLoading = true;
                    $scope.showOverlay = true;
                    controller.Delete($scope.serviceName, id, function (data) {
                        $scope.cancel();
                        $scope.categoryId = null;
                        /*if (parentId != null)
                            $scope.editItem(parentId);
                        else*/
                        $scope.clearItem();
                        $scope.IsLoading = true;
                        $scope.showOverlay = true;
                        $scope.getCategoryTree();
                        $scope.IsLoading = false;
                        $scope.showOverlay = false;
                    }, function () { $scope.IsLoading = false; }, $scope.WorkingAreaQueryString);
                }
            };
            $scope.Move = function (toMove, moveTo, moveMode) {
                $scope.IsLoading = true;
                $scope.showOverlay = true;
                var queryString = '';
                if (toMove != null && moveTo != null && (moveMode != null && moveMode != '')) {
                    queryString = "tmId=" + toMove.data.Id;
                    queryString += "&mtId=" + moveTo.data.Id;
                    queryString += "&mM=" + moveMode;
                    queryString += "&oP=" + toMove.data.Position;
                    queryString += "&rP=" + moveTo.data.Position;
                    queryString += "&opId=" + toMove.data.ParentId;
                    queryString += "&npId=" + moveTo.data.ParentId;
                }
                else
                    queryString = "";
                controller.CallPutAction($scope.serviceName, "Move", null, null, function (data) {
                    $scope.getCategoryTree();
                    $scope.IsLoading = false;
                    $scope.showOverlay = false;
                }, function () {
                    $scope.getCategoryTree();
                    $scope.IsLoading = false;
                    $scope.showOverlay = false;
                }, queryString + $scope.WorkingAreaQueryString, true);
            };
            $scope.cancel = function () {
                $scope.showactionmenu = false;
                $scope.showOverlay = false;
                /*$scope.IsNew = false;
                $scope.IsEdit = false;*/
            };
            $scope.afterReload = function () {
                if ($scope.categoryId != null && $scope.categoryId != '') {
                    $scope.activateNode($scope.categoryId);
                    //$scope.editItem($scope.categoryId);
                }
            };
            $scope.RightClick = function (event, data) {
                var tree = eval('$("#menu_tree").fancytree("getTree")');
                var node = tree.getNodeByKey(data);
                $scope.subMenuId = node.data.Id;
                $scope.showactionmenu = true;
                $scope.showOverlay = true;
                $scope.shownew = true;
                $scope.showedit = true;
                $scope.showunlock = false;
                if ($scope.subMenuId == $scope.categoryId)
                    $scope.showunlock = true;
                $scope.categoryId = node.data.Id;
                $scope.showdelete = false;
                if ((node.data.children == undefined || node.data.children == null) && node.data.WorkingAreaId == null)
                    $scope.showdelete = true;
                $scope.activateNode($scope.subMenuId);
                $scope.menuTopPos = {
                    "top": (event.clientY + 15) + "px",
                    "left": (event.clientX - 55) + "px"
                };
                $scope.safeApply();
            };
            $scope.Click = function (event, data) {
                //open detail
                $scope.IsNew = false;
                $scope.IsEdit = true;
                if ($scope.categoryId != null)
                    $scope.unlockItem($scope.categoryId);
                $scope.categoryId = data.arg2.node.data.Id;
                $scope.editItem($scope.categoryId);
            };
            $scope.visit = function (item, delegate) {
                if (item == null || item.children == null)
                    return;
                var len = item.children.length;
                delegate(item);
                for (var i = 0; i < len; i++) {
                    $scope.visit(item.children[i], delegate);
                }
            };
            $scope.calculateAvailableLanguages = function () {
                if ($scope.Model != null && $scope.Languages != null && $scope.Languages.length > 0) {
                    $scope.AvailableLanguages = new Array();
                    var i = 0;
                    var j = 0;
                    for (i = 0; i < $scope.Languages.length; i++) {
                        var add = true;
                        for (j = 0; j < $scope.Model.Translations.length; j++) {
                            if ($scope.Model.Translations[j].Language != null && $scope.Model.Translations[j].Language.LanguageId == $scope.Languages[i].LanguageId)
                                add = false;
                        }
                        if (add)
                            $scope.AvailableLanguages.splice(0, 0, $scope.Languages[i]);
                    }
                }
            };
            // discard changes and close page and menu form 
            $scope.discardChanges = function () {
                if ($scope.IsEdit && $scope.unlockItem != null) {
                    $scope.unlockItem($scope.categoryId);
                }
                if ($scope.urlVars[5] != null && $scope.urlVars[5] != '') {
                    location.href = "/en/admin/cms/menu";
                    return;
                }
                $scope.categoryId = null;
                $scope.Model = null;
            };
            $scope.removeTranslationFromList = function (index) {
                $scope.Model.Translations.splice(index, 1);
                $scope.calculateAvailableLanguages();
            };
            $scope.addTranslation = function () {
                if ($scope.newTranslation == null)
                    return;
                $scope.newTranslation.CategoryId = $scope.Model.CategoryId;
                var i = 0;
                for (i = 0; i < $scope.Languages.length; i++) {
                    if ($scope.Languages[i].LanguageId == $scope.newTranslation.Language.LanguageId) {
                        $scope.newTranslation.Language = $scope.Languages[i];
                        break;
                    }
                }
                if ($scope.Model.Translations == null) {
                    $scope.Model.Translations = new Array($scope.newTranslation);
                    $scope.calculateAvailableLanguages();
                    return;
                }
                if ($scope.Model.Translations.length == 0) {
                    $scope.Model.Translations.splice(-1, 0, $scope.newTranslation);
                    $scope.calculateAvailableLanguages();
                    return;
                }
                var i = 0;
                var removeList = new Array();
                for (i = 0; i < $scope.Model.Translations.length; i++) {
                    if ($scope.Model.Translations[i] == null ||
                        $scope.Model.Translations[i].Title == null ||
                        $scope.Model.Translations[i].Title == '') {
                        removeList.splice(0, 0, i);
                    }
                }
                for (i = 0; i < removeList.length; i++) {
                    $scope.Model.Translations.splice(removeList[i], 1);
                }
                $scope.Model.Translations.splice($scope.Model.Translations.length, 0, $scope.newTranslation);
                $scope.newTranslation = new Module.VMCategoryDetailTranslation();
                $scope.calculateAvailableLanguages();
            };
            $scope.unlockItem = function (id) {
                $scope.cancel();
                $scope.IsLoading = true;
                controller.CallPutAction($scope.serviceName, "Unlock", id, null, function (data) {
                    $scope.showOverlay = false;
                    $scope.IsLoading = false;
                }, function () {
                    $scope.IsLoading = false;
                    $scope.showOverlay = false;
                    MessagesModule.MessagesController.prototype.ShowMessageBox("Unlock Error!", MessagesModule.MessageBoxType.ERROR, "Error");
                }, $scope.WorkingAreaQueryString);
            };
            $scope.forceUnlockItem = function (id, callback) {
                $scope.cancel();
                $scope.IsLoading = true;
                controller.CallPutAction($scope.serviceName, "ForceUnlock", id, null, function (data) {
                    $scope.showOverlay = false;
                    $scope.IsLoading = false;
                    if (callback != null)
                        callback(id);
                }, function () {
                    $scope.IsLoading = false;
                    $scope.showOverlay = false;
                    MessagesModule.MessagesController.prototype.ShowMessageBox("Unlock Error!", MessagesModule.MessageBoxType.ERROR, "Error");
                }, $scope.WorkingAreaQueryString);
            };
            $scope.unlockall = function () {
                $scope.IsLoading = true;
                controller.CallPutAction($scope.serviceName, "ForceUnlockAll", null, null, function (data) {
                    $scope.IsLoading = false;
                    $scope.showOverlay = false;
                    MessagesModule.MessagesController.prototype.ShowMessageBox("Successfully unlocked", MessagesModule.MessageBoxType.SUCCESS, "");
                }, function () {
                    $scope.IsLoading = false;
                    $scope.showOverlay = false;
                    MessagesModule.MessagesController.prototype.ShowMessageBox("Unlock Error!", MessagesModule.MessageBoxType.ERROR, "Error");
                }, $scope.WorkingAreaQueryString);
            };
            _this.GetCache("TRANSLATEDLANGUAGES", function (data) {
                $scope.Languages = data.Data;
            });
            $scope.getCategoryTree();
            return _this;
        }
        return CategoryController;
    }(SearchModule.GenericSearchController));
    AdminCategoryModule.CategoryController = CategoryController;
})(AdminCategoryModule || (AdminCategoryModule = {}));
angular.module('minervaApp').controller("AdminCategoryModule.CategoryController", ["$scope", "$http", "$timeout", AdminCategoryModule.CategoryController]);
//CategoryController.js.map;
/*! GlobalisationLoadController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
// module to manage file uploads 
var GlobalisationLoadModule;
(function (GlobalisationLoadModule) {
    // file system upload file controller
    var GlobalisationLoadController = /** @class */ (function (_super) {
        __extends(GlobalisationLoadController, _super);
        function GlobalisationLoadController($scope, $http, $timeout) {
            var _this = _super.call(this, $http, $scope) || this;
            var controller = _this;
            // lock filesystem
            $scope.getGlobalisationList = function () {
                controller.CallGetAction("GlobalisationUpload", "GetList", null, function (data) {
                    $scope.GlobalisationFileList = data.Data;
                });
            };
            $scope.getPoetryList = function () {
                controller.CallGetAction("PoetryUpload", "GetList", null, function (data) {
                    $scope.PoetryFileList = data.Data;
                });
            };
            // upload/update file callback
            $scope.updateGlobalisationFile = function (newfile) {
                if (newfile.Type == 1) {
                    alert(newfile.Message);
                    return;
                }
                $scope.UploadedGlobalisationFile = newfile.Data[1];
                $scope.getGlobalisationList();
                //location.href = location.href;
                //$timeout(function () {
                //    $scope.getGlobalisationList();
                //}, 3000);
            };
            // upload/update file callback
            $scope.updatePoetryFile = function (newfile) {
                if (newfile.Type == 1) {
                    alert(newfile.Message);
                    return;
                }
                $scope.UploadedPoetryFile = newfile.Data[1];
                $scope.getPoetryList();
                //location.href = location.href;
                //$timeout(function () {
                //    $scope.getPoetryList();
                //}, 3000);
            };
            $scope.startGlobalisationImport = function (file) {
                controller.CallPostAction("GlobalisationUpload", "StartImport", file.FileId, null, function (data) {
                    $scope.getGlobalisationList();
                    //location.href = location.href;
                    $timeout(function () {
                        $scope.getGlobalisationList();
                    }, 3000);
                }, null, "lang=" + file.LanguageId);
            };
            $scope.startPoetryImport = function (file) {
                if (file.LanguageId == null || file.LanguageId == '') {
                    alert("Select a language to start the import");
                    return;
                }
                controller.CallPostAction("PoetryUpload", "StartImport", file.FileId, null, function (data) {
                    $scope.getPoetryList();
                    //location.href = location.href;
                    $timeout(function () {
                        $scope.getPoetryList();
                    }, 3000);
                }, null, "lang=" + file.LanguageId);
            };
            $scope.isImportPending = function (id) {
                var r = $scope.isGlobalisationPending(id);
                if (r)
                    return r;
                r = $scope.isPoetryPending(id);
                return r;
            };
            $scope.isPoetryPending = function (id) {
                var i = 0;
                if ($scope.PoetryFileList != null && $scope.PoetryFileList.length > 0) {
                    for (i = 0; i < $scope.PoetryFileList.length; i++) {
                        if ($scope.PoetryFileList[i].FileId != id && ($scope.PoetryFileList[i].StatusId == null
                            || $scope.PoetryFileList[i].StatusId == ""
                            || $scope.PoetryFileList[i].StatusId == "TODO"
                            || $scope.PoetryFileList[i].StatusId == "RUNNING"))
                            return true;
                    }
                }
                return false;
            };
            $scope.isGlobalisationPending = function (id) {
                var i = 0;
                if ($scope.GlobalisationFileList != null && $scope.GlobalisationFileList.length > 0) {
                    for (i = 0; i < $scope.GlobalisationFileList.length; i++) {
                        if ($scope.GlobalisationFileList[i].FileId != id && ($scope.GlobalisationFileList[i].StatusId == null
                            || $scope.GlobalisationFileList[i].StatusId == ""
                            || $scope.GlobalisationFileList[i].StatusId == "TODO"
                            || $scope.GlobalisationFileList[i].StatusId == "RUNNING"))
                            return true;
                    }
                }
                return false;
            };
            $scope.deleteFile = function (id) {
                var r = confirm("Do you want to delete the file?");
                if (r == true) {
                    controller.Delete("GlobalisationUpload", id, function (data) {
                        $scope.getGlobalisationList();
                        $scope.getPoetryList();
                        //location.href = location.href;
                        $timeout(function () {
                            $scope.getGlobalisationList();
                            $scope.getPoetryList();
                        }, 3000);
                    });
                }
            };
            $scope.showErrorMessageAlert = function (text) {
                if (text == null || text == '')
                    return;
                alert(text);
            };
            _this.GetCache("TRANSLATEDLANGUAGES", function (data) {
                var i = 0;
                for (i = 0; i < data.Data.length; i++) {
                    data.Data[i].Language = data.Data[i].LanguageId + " - " + data.Data[i].Language;
                }
                $scope.Languages = data.Data; /*$scope.RepAuthCountries = data.Data;*/
            });
            $scope.getGlobalisationList();
            $scope.getPoetryList();
            return _this;
        }
        return GlobalisationLoadController;
    }(HttpModule.HttpController));
    GlobalisationLoadModule.GlobalisationLoadController = GlobalisationLoadController;
})(GlobalisationLoadModule || (GlobalisationLoadModule = {}));
angular.module('minervaApp').controller("GlobalisationLoadModule.GlobalisationLoadController", ["$scope", "$http", "$timeout", GlobalisationLoadModule.GlobalisationLoadController]);
//GlobalisationLoadController.js.map;
/*! HealthIndexesMonitoringController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var HealthIndexesMonitoringModule;
(function (HealthIndexesMonitoringModule) {
    var HealthIndexesMonitoringController = /** @class */ (function (_super) {
        __extends(HealthIndexesMonitoringController, _super);
        function HealthIndexesMonitoringController($scope, $http) {
            var _this = _super.call(this, $scope, $http, "Admin", "HealthIndexesMonitoring", false) || this;
            _this.GetHealthMonitoringHTML("HealthIndexesMonitoring", $scope);
            return _this;
        }
        // get the health monitoring html from the server to print on the page
        HealthIndexesMonitoringController.prototype.GetHealthMonitoringHTML = function (servicename, scope) {
            var controller = this;
            controller.List(servicename, function (data) {
                scope.HealthIndexesMonitoring = data.Data;
            });
        };
        return HealthIndexesMonitoringController;
    }(BaseModule.CrudBaseController));
    HealthIndexesMonitoringModule.HealthIndexesMonitoringController = HealthIndexesMonitoringController;
})(HealthIndexesMonitoringModule || (HealthIndexesMonitoringModule = {}));
angular.module('minervaApp').controller("HealthIndexesMonitoringModule.HealthIndexesMonitoringController", ["$scope", "$http", HealthIndexesMonitoringModule.HealthIndexesMonitoringController]);
//HealthIndexesMonitoringController.js.map;
/*! HealthMonitoringController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var HealthMonitoringModule;
(function (HealthMonitoringModule) {
    var HealthMonitoringController = /** @class */ (function (_super) {
        __extends(HealthMonitoringController, _super);
        function HealthMonitoringController($scope, $http) {
            var _this = _super.call(this, $scope, $http, "Admin", "HealthMonitoring", false) || this;
            _this.GetHealthMonitoringHTML("HealthMonitoring", $scope);
            return _this;
        }
        // get the health monitoring html from the server to print on the page
        HealthMonitoringController.prototype.GetHealthMonitoringHTML = function (servicename, scope) {
            var controller = this;
            controller.List(servicename, function (data) {
                scope.HealthMonitoring = data.Data;
            });
        };
        return HealthMonitoringController;
    }(BaseModule.CrudBaseController));
    HealthMonitoringModule.HealthMonitoringController = HealthMonitoringController;
})(HealthMonitoringModule || (HealthMonitoringModule = {}));
angular.module('minervaApp').controller("HealthMonitoringModule.HealthMonitoringController", ["$scope", "$http", HealthMonitoringModule.HealthMonitoringController]);
//HealthMonitoringController.js.map;
/*! ProfileController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var ProfileModule;
(function (ProfileModule) {
    var ProfileController = /** @class */ (function (_super) {
        __extends(ProfileController, _super);
        function ProfileController($scope, $http) {
            var _this = 
            // Initialize base class
            _super.call(this, $scope, $http, "Minerva", "Profile", false) || this;
            var controller = _this;
            //SDD            -120.9762  symbol (+-) degree.decimals         (DATABASE STANDARD)
            //SDMS           -41°25'01" symbol (+-) degree°minutes'seconds"
            //CDD            N 120.9762  cardinal (NS/EW) degree.decimals
            //CDMS           N 41°25'01" cardinal (NS/EW) degree°minutes'seconds"
            $scope.GisFormatsList = [{
                    id: "SDD",
                    value: "(-)DD.dddddd - eg. -12.345678"
                }, {
                    id: "SDMS",
                    value: "(-)DD°MM'SS.dddddd\" - eg. -12°34'56.123456\""
                }, {
                    id: "CDD",
                    value: "N/S E/W DD.dddddd - eg. S 12.345678"
                }, {
                    id: "CDMS",
                    value: "N/S E/W DD°MM'SS.dddddd\" - eg. S 12°34'56.123456\""
                }
            ];
            // fill record per page and search result list view dropdowns
            $scope.RecordPerPageList = [{
                    PageNum: 5,
                    sPageNum: "5"
                }, {
                    PageNum: 10,
                    sPageNum: "10"
                }, {
                    PageNum: 20,
                    sPageNum: "20"
                }, {
                    PageNum: 50,
                    sPageNum: "50"
                }
            ];
            $scope.ViewSearchResultList = [{
                    ViewChar: "L",
                    ViewName: "List view"
                },
                {
                    ViewChar: "G",
                    ViewName: "Grid view"
                }];
            $scope.Model = null;
            // ********************************** Base class methods implementation ********************************************* //
            // get model method called by base super ts class
            $scope.getUser = function () {
                controller.Lock($scope.serviceName, '', null, function (data) {
                    $scope.Model = data.Data;
                    $scope.IdModel = $scope.Model.UserId;
                    $scope.IsEdit = true;
                    $scope.registerOutFormEvents();
                    $scope.IsLockedByMe = true;
                    $scope.setSendingNotificationString();
                });
            };
            // check mandatory field is called by base super ts class, within loadpage methos. It is mandatory.
            $scope.checkMandatoryFields = function (successCallBack) {
                successCallBack();
            };
            //emars
            //this.GetCache("countrylanguages", function (data: Module.VMResult) { $scope.CountryLanguages = data.Data; });
            // MUST BE REPLACED WITH RADIOBUTTON. this method simulate a radiobutton behaviour 
            $scope.changeNotifySelection = function (IsSendingNotificationALL, IsSendingNotificationOWNED, IsSendingNotificationNONE) {
                $scope.Model.IsSendingNotificationALL = IsSendingNotificationALL;
                $scope.Model.IsSendingNotificationOWNED = IsSendingNotificationOWNED;
                $scope.Model.IsSendingNotificationNONE = IsSendingNotificationNONE;
            };
            $scope.setSendingNotificationString = function () {
                if ($scope.Model != null) {
                    if ($scope.Model.IsSendingNotificationALL)
                        $scope.NotificationSelectedValue = "ALL";
                    if ($scope.Model.IsSendingNotificationOWNED)
                        $scope.NotificationSelectedValue = "NEW";
                    if ($scope.Model.IsSendingNotificationNONE)
                        $scope.NotificationSelectedValue = "NO";
                }
            };
            // get country object by id from cache 
            $scope.getCountryById = function (countryId) {
                if (countryId == null)
                    return null;
                if ($scope.ProfileCountries != null) {
                    var i = 0;
                    for (i = 0; i < $scope.ProfileCountries.length; i++) {
                        if ($scope.ProfileCountries[i].CountryId == countryId) {
                            return $scope.ProfileCountries[i];
                        }
                    }
                }
                return null;
            };
            //super($scope, $http, "Minerva", "Profile", false);
            $scope.doNotUnlockOnExit = false;
            //$scope.wasChanged = true;
            // Load cache data
            controller.GetCache("countries", function (data) {
                $scope.ProfileCountries = data.Data;
                $scope.UserCountries = data.Data;
                controller.GetCache("translatedlanguages", function (data) {
                    $scope.SecondaryLanguages = data.Data;
                    $scope.PreferredLanguages = data.Data;
                    $scope.getUser();
                });
            });
            return _this;
            // Load base CRUD methods and properties
        }
        return ProfileController;
    }(BaseModule.CrudBaseController));
    ProfileModule.ProfileController = ProfileController;
})(ProfileModule || (ProfileModule = {}));
angular.module('minervaApp').controller("ProfileModule.ProfileController", ["$scope", "$http", ProfileModule.ProfileController]);
//ProfileController.js.map;
/*! SearchWorkingAreaController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var WorkingAreaModule;
(function (WorkingAreaModule) {
    /**********************************   SEARCH/VIEW CONTROLLER ********************************************/
    var SearchWorkingAreaController = /** @class */ (function (_super) {
        __extends(SearchWorkingAreaController, _super);
        function SearchWorkingAreaController($scope, $http, $timeout) {
            var _this = this;
            $scope.searchServiceName = "WorkingArea";
            _this = _super.call(this, $scope, $http) || this;
            var controller = _this;
            // Method called to search cms content
            $scope.search = function (pageNr) {
                if (pageNr === void 0) { pageNr = null; }
                if (pageNr == null || pageNr < 1)
                    pageNr = 1;
                // add searching parameter to query string
                var query = "";
                query = query + "searchingtext=" + ($scope.SearchingText != undefined ? encodeURIComponent($scope.SearchingText) : '');
                query = query + "&currentPage=" + pageNr;
                query = query + "&rpp=" + $scope.RecordPerPage;
                query = query + "&sortby=" + ($scope.sortSelectedItem != undefined ? $scope.sortSelectedItem : '');
                query = query + "&sortdir=" + ($scope.sortDirection != undefined ? $scope.sortDirection : '');
                controller.Search($scope.searchServiceName, query, function (data) {
                    var searchResult = data.Data;
                    if (searchResult != null) {
                        $scope.paging.maxPages = searchResult.maxPages;
                        $scope.paging.currentPage = searchResult.currentPage;
                        $scope.paging.totlaResults = searchResult.totlaResults;
                        $scope.paging.GetSelectablePages();
                        $scope.results = searchResult.resultSet;
                    }
                    else {
                        $scope.paging.maxPages = 0;
                        $scope.paging.currentPage = 1;
                        $scope.paging.totlaResults = 0;
                        $scope.paging.GetSelectablePages();
                        $scope.results = null;
                    }
                });
            };
            // reset all search filters and call a new searh
            $scope.resetSearch = function () {
                $scope.paging.currentPage = 1;
                $scope.SearchingText = "";
                $scope.search();
            };
            // launch first search
            $scope.search();
            return _this;
        }
        return SearchWorkingAreaController;
    }(SearchModule.GenericSearchController));
    WorkingAreaModule.SearchWorkingAreaController = SearchWorkingAreaController;
})(WorkingAreaModule || (WorkingAreaModule = {}));
angular.module('minervaApp').controller("WorkingAreaModule.SearchWorkingAreaController", ["$scope", "$http", "$timeout", WorkingAreaModule.SearchWorkingAreaController]);
//SearchWorkingAreaController.js.map;
/*! WorkingAreaController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var WorkingAreaModule;
(function (WorkingAreaModule) {
    var WorkingAreaController = /** @class */ (function (_super) {
        __extends(WorkingAreaController, _super);
        function WorkingAreaController($scope, $http, $timeout) {
            var _this = this;
            $scope.showAddUserModal = false;
            $scope.showSearchUserModal = false;
            $scope.addNewUserInt = 1;
            _this = _super.call(this, $scope, $http, "Admin", "WorkingArea", false) || this;
            /**********************************************************************************************************************************************/
            /************************************** COPIED FROM GENERICSEARCH CONTROLLER ***********************************************************/
            /**********************************************************************************************************************************************/
            $scope.searchUsersServiceName = "User";
            ///////// Initialize record per page number and set the default value from web config ///////////////////
            $scope.RecordPerPage = 0;
            $scope.RecordPerPageList = [{
                    PageNum: 5,
                    sPageNum: "5"
                },
                {
                    PageNum: 10,
                    sPageNum: "10"
                }, {
                    PageNum: 20,
                    sPageNum: "20"
                },
                {
                    PageNum: 50,
                    sPageNum: "50"
                }
            ];
            $scope.RecordPerPage = $scope.RecordPerPageList[0].PageNum;
            try {
                $scope.DefaultRecordPerPage = parseInt($("#rpp_def").val());
                var i = 0;
                for (i = 0; i < $scope.RecordPerPageList.length; i++) {
                    if ($scope.DefaultRecordPerPage == $scope.RecordPerPageList[i].PageNum) {
                        $scope.RecordPerPage = $scope.RecordPerPageList[i].PageNum;
                        break;
                    }
                }
            }
            catch (e) { }
            $scope.paging = new PagingModule.PagingController();
            /**********************************************************************************************************************************************/
            /************************************** END OF COPIED FROM GENERICSEARCH CONTROLLER ***********************************************************/
            /**********************************************************************************************************************************************/
            var controller = _this;
            $scope.loadPage = function () {
                $scope.IsNew = ($scope.urlVars[5] == undefined || $scope.urlVars[5] == null || $scope.urlVars[5] == '');
                $scope.IsEdit = !$scope.IsNew;
                if ($scope.IsEdit) {
                    $scope.IdModel = $scope.urlVars[5];
                    $scope.getModel($scope.IdModel);
                }
                else {
                    $scope.getNewModelInstance();
                }
            };
            /******************************************************************************************************************/
            /************************************** SEARCH SECTION ***********************************************************/
            /*****************************************************************************************************************/
            // Method called to searchUsers cms content
            $scope.search = function (pageNr) {
                if (pageNr === void 0) { pageNr = null; }
                if (pageNr == null || pageNr < 1)
                    pageNr = 1;
                // add searchUsersing parameter to query string
                var query = "";
                query = query + "searchingtext=" + ($scope.SearchingText != undefined ? encodeURIComponent($scope.SearchingText) : '');
                query = query + "&statusId=ACTIVATED";
                query = query + "&currentPage=" + pageNr;
                query = query + "&rpp=10";
                controller.Search($scope.searchUsersServiceName, query, function (data) {
                    var searchUsersResult = data.Data;
                    $scope.paging.maxPages = searchUsersResult.maxPages;
                    $scope.paging.currentPage = searchUsersResult.currentPage;
                    $scope.paging.totlaResults = searchUsersResult.totlaResults;
                    $scope.paging.GetSelectablePages();
                    $scope.results = searchUsersResult.resultSet;
                    $scope.safeApply();
                });
            };
            // Implements check super mandatory Event fields function
            $scope.checkMandatoryFields = function (successCallBack) {
                if (successCallBack != null)
                    successCallBack();
            };
            // reset all searchUsers filters and call a new searh
            $scope.resetUsersSearch = function () {
                $scope.paging.currentPage = 1;
                $scope.SearchingText = "";
                //$scope.SelectedLanguage = null;
                $scope.search();
            };
            // Default behavior for content click
            $scope.selectUserAction = function (userId, username) {
                var exists = false;
                angular.forEach($scope.Model.UsersLinked, function (fn, index) {
                    if (fn.UserId === userId) {
                        exists = true;
                        return;
                    }
                });
                if (!exists) {
                    var addUser = new Module.Admin.VMUserLinked();
                    addUser.UserId = userId;
                    addUser.Email = username;
                    addUser.Rights = angular.copy($scope.WARights); //new Module.VMSelectableBase()[0];
                    $scope.Model.UsersLinked.push(addUser);
                }
                else {
                    MessagesModule.MessagesController.prototype.ShowMessageBox("User already exists.", MessagesModule.MessageBoxType.ERROR, "ERROR");
                }
                $scope.showSearchUserModal = false;
            };
            $scope.removeUserLinked = function (user) {
                if (user != null && $scope.Model.UsersLinked != null) {
                    for (var i = 0; i < $scope.Model.UsersLinked.length; ++i) {
                        if ($scope.Model.UsersLinked[i].UserId == user.UserId) {
                            $scope.Model.UsersLinked.splice(i, 1);
                            return;
                        }
                    }
                }
            };
            $scope.validateEmail = function (email) {
                var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
                return re.test(email);
            };
            $scope.addNewUser = function () {
                if ($scope.addNewUserEmail.trim() != '' && $scope.validateEmail($scope.addNewUserEmail)) {
                    var exists = false;
                    angular.forEach($scope.Model.UsersLinked, function (fn, index) {
                        if (fn.Email.toLowerCase() === $scope.addNewUserEmail.trim().toLowerCase()) {
                            exists = true;
                            return;
                        }
                    });
                    if (!exists) {
                        var addUser = new Module.Admin.VMUserLinked();
                        addUser.UserId = $scope.addNewUserInt.toString();
                        addUser.Email = $scope.addNewUserEmail;
                        addUser.Rights = angular.copy($scope.WARights); //new Module.VMSelectableBase()[0];
                        $scope.Model.UsersLinked.push(addUser);
                    }
                    else {
                        MessagesModule.MessagesController.prototype.ShowMessageBox("User already exists.", MessagesModule.MessageBoxType.ERROR, "ERROR");
                    }
                }
                else {
                    MessagesModule.MessagesController.prototype.ShowMessageBox("Email not valid or not present.", MessagesModule.MessageBoxType.ERROR, "ERROR");
                }
                $scope.showAddUserModal = false;
                $scope.addNewUserInt++;
                $scope.addNewUserEmail = "";
            };
            /******************************************************************************************************************/
            /************************************** END SEARCH SECTION ***********************************************************/
            /*****************************************************************************************************************/
            /* Seleziona il modello del right nella lista dei rigths */
            $scope.getModelSelectInRightsUser = function (listRights, right) {
                if (listRights != null) {
                    for (var i = 0; i < listRights.length; i++) {
                        if (listRights[i].Id == right.Id) {
                            return listRights[i];
                        }
                        ;
                    }
                }
            };
            /* Seleziona il modello del tools nella lista dei tools in base al rights */
            $scope.getModelSelectTool = function (right) {
                if ($scope.Model != null && $scope.Model.Tools != null) {
                    for (var i = 0; i < $scope.Model.Tools.length; i++) {
                        if ($scope.Model.Tools[i].Rights != null) {
                            for (var j = 0; j < $scope.Model.Tools[i].Rights.length; j++) {
                                if ($scope.Model.Tools[i].Rights[j].RightId == right.Id) {
                                    return $scope.Model.Tools[i];
                                }
                                ;
                            }
                        }
                    }
                }
            };
            $scope.afterSaveCallBack = function () {
                location.href = location.href;
            };
            $scope.addModelCallBack = function (model) {
                location.href = location.href + "/" + model.WorkingAreaId;
            };
            $scope.loadPage();
            _this.GetCache("WA_RIGHTS", function (data) {
                $scope.WARights = data.Data;
                controller.GetCache("WA_TOOLS_RIGHTS", function (data) {
                    $scope.WAToolsRights = data.Data;
                });
            });
            return _this;
        }
        return WorkingAreaController;
    }(BaseModule.CrudBaseController));
    WorkingAreaModule.WorkingAreaController = WorkingAreaController;
})(WorkingAreaModule || (WorkingAreaModule = {}));
angular.module('minervaApp').controller("WorkingAreaModule.WorkingAreaController", ["$scope", "$http", "$timeout", WorkingAreaModule.WorkingAreaController]);
//WorkingAreaController.js.map;
/*! CMSEventDetailController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var CMSModule;
(function (CMSModule) {
    var CMSEventDetailController = /** @class */ (function (_super) {
        __extends(CMSEventDetailController, _super);
        function CMSEventDetailController($scope, $http) {
            var _this = _super.call(this, $scope, $http) || this;
            var controller = _this;
            $scope.WorkingAreaUrlId = $scope.urlVars[3];
            $scope.EventTypeCode = $scope.urlVars[6];
            $scope.EventId = $scope.urlVars[7];
            $scope.getEvent = function () {
                controller.CallWAGetAction('CMSEvent', 'Get', $scope.WorkingAreaUrlId, [$scope.EventTypeCode, $scope.EventId], function (data) {
                    $scope.Event = Module.VMSearchResult = data.Data;
                }, null, true);
            };
            $scope.getEvent();
            $scope.getTranslation = function (Language, Key) {
                if (!$scope.Event)
                    return '';
                var trans = null;
                trans = $scope.Event.Translations.filter(function (x) { return x.Language.LanguageId.toUpperCase() == Language.toUpperCase(); })[0];
                if (trans == null)
                    trans = $scope.Event.Translations.filter(function (x) { return x.Language.LanguageId.toUpperCase() == 'EN'; })[0];
                var value = eval('trans[Key]');
                if (value.length == 0)
                    value = '<span class=\"EventDescEmpty\">Empty ' + Key + '.</span>';
                return value;
            };
            $scope.getTimeZone = function () {
                if (!$scope.Event)
                    return '';
                return $scope.Event.TimeZone + ' (UTC' + moment.tz($scope.Event.TimeZone).format('Z') + ')';
            };
            return _this;
        }
        return CMSEventDetailController;
    }(BaseModule.BaseController));
    CMSModule.CMSEventDetailController = CMSEventDetailController;
})(CMSModule || (CMSModule = {}));
angular.module('minervaApp').controller("CMSModule.CMSEventDetailController", ["$scope", "$http", CMSModule.CMSEventDetailController]);
//CMSEventDetailController.js.map;
/*! CMSEventListController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var CMSModule;
(function (CMSModule) {
    var CMSEventListController = /** @class */ (function (_super) {
        __extends(CMSEventListController, _super);
        function CMSEventListController($scope, $http) {
            var _this = _super.call(this, $scope, $http) || this;
            var controller = _this;
            $scope.WorkingAreaUrlId = $scope.urlVars[3];
            $scope.EventTypeCode = $scope.urlVars[6];
            $scope.list = function () {
                controller.CallWAGetAction('CMSEvent', 'List', $scope.WorkingAreaUrlId, [$scope.EventTypeCode], function (data) {
                    $scope.Events = Module.VMSearchResult = data.Data;
                }, null, true);
            };
            $scope.list();
            $scope.getTranslation = function (Event, Language, Key) {
                var trans = null;
                trans = Event.Translations.filter(function (x) { return x.Language.LanguageId.toUpperCase() == Language.toUpperCase(); })[0];
                if (trans == null)
                    trans = Event.Translations.filter(function (x) { return x.Language.LanguageId.toUpperCase() == 'EN'; })[0];
                var value = eval('trans[Key]');
                if (value.length == 0)
                    value = '<p></p>';
                var isLong = (value.length > 256);
                return value.substr(0, 255) + (isLong ? '...' : '');
            };
            $scope.getTimeZone = function (TimeZone) {
                return TimeZone + ' (UTC' + moment.tz(TimeZone).format('Z') + ')';
            };
            return _this;
        }
        return CMSEventListController;
    }(BaseModule.BaseController));
    CMSModule.CMSEventListController = CMSEventListController;
})(CMSModule || (CMSModule = {}));
angular.module('minervaApp').controller("CMSModule.CMSEventListController", ["$scope", "$http", CMSModule.CMSEventListController]);
//CMSEventListController.js.map;
/*! MenuManagement.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var CMSModule;
(function (CMSModule) {
    var MenuManagementController = /** @class */ (function (_super) {
        __extends(MenuManagementController, _super);
        function MenuManagementController($scope, $http, $timeout) {
            var _this = 
            // Initialize base class
            _super.call(this, $scope, $http) || this;
            var controller = _this;
            // Init content search
            $scope.MimeOption = ContentResourceSearchModule.MimeOptions.All;
            $scope.MimeOptionsVisibility = true;
            $scope.ContentTypeVisibility = true;
            $scope.NewWebContentVisibility = true;
            $scope.UploadPartialVisibility = true;
            $scope.UploadFilePermissionVisibility = false;
            $scope.UnlockVisibility = false;
            $scope.DownloadVisibility = false;
            $scope.FolderVisibility = false;
            $scope.IsMenuFilter = true;
            $scope.IsNew = false;
            $scope.IsEdit = false;
            $scope.IsFirstLoad = true;
            $scope.Destination = new Array();
            $scope.Destination.push({ DestinationId: "TOP", Destination: "TOP" });
            $scope.Destination.push({ DestinationId: "LEFT", Destination: "LEFT" });
            $scope.showOverlay = false;
            $scope.showModal = false;
            $scope.serviceName = "Menu";
            if ($scope.urlVars[5] != undefined && $scope.urlVars[5] != null && $scope.urlVars[5] != '' && $scope.IsFirstLoad)
                $scope.menuId = $scope.urlVars[5];
            //var mfsLinkId = controller.GetParameterByName('fId');
            //if (mfsLinkId != null && mfsLinkId != '' && mfsLinkId != 'undefined' && mfsLinkId != 'null') {
            //    controller.CallGetAction($scope.serviceName, "Lock", $scope.menuId, function (data: Module.VMResult) {
            //        $scope.Model = data.Data;
            //        controller.CallGetAction("FileSystem", "GetFileSystemMinInfo", mfsLinkId, function (data: Module.VMResult) {
            //            if (data != null && data.Data != null) {
            //                $scope.Model.TargetId = mfsLinkId;
            //                $scope.Model.TargetName = data.Data.Name;
            //                $scope.Model.TargetMimeType = data.Data.MimeType;
            //                $scope.save(function () {
            //                    location.href = "/en/admin/cms/menu/" + $scope.menuId;
            //                });
            //            }
            //        });
            //    }, function () {
            //        location.href = "/en/admin/cms/menu";
            //    });
            //}
            $scope.getMenuTree = function () {
                // get menu id from url
                var queryString = '';
                if ($scope.menuId != null && $scope.menuId != '' && $scope.IsFirstLoad)
                    queryString = "mId=" + $scope.menuId;
                var waId = controller.GetParameterByName('waId');
                if (waId != null && waId != '' && waId != 'undefined') {
                    $scope.WorkingAreaId = waId;
                    $scope.WorkingAreaQueryString = "&waId=" + waId;
                    if (queryString == '')
                        queryString = "waId=" + $scope.WorkingAreaId;
                    else
                        queryString = queryString + "&waId=" + $scope.WorkingAreaId;
                }
                $scope.IsLoading = true;
                controller.CallGetAction($scope.serviceName, "GetTree", null, function (data) {
                    $scope.RootModel = data.Data;
                    if ($scope.menuId == null || $scope.menuId == '' || $scope.menuId == undefined)
                        $scope.menuId = data.Data.children[0].Id;
                    $scope.visit($scope.RootModel, function (item) {
                        if (item.icon == null)
                            item.icon = "/minerva/themes/minerva/images/icons/treemenu/icon_menu.png";
                        if (item.ParentId != null) {
                            item.expanded = false;
                        }
                        else {
                            item.expanded = true;
                        }
                    });
                    if ($scope.menuId != null && $scope.menuId != '')
                        $scope.editItem($scope.menuId);
                    $scope.IsLoading = false;
                    $scope.IsFirstLoad = false;
                }, function () { $scope.IsLoading = false; }, queryString);
            };
            $scope.clearItem = function () {
                $scope.showactionmenu = false;
                $scope.showOverlay = false;
                $scope.IsNew = false;
                $scope.IsEdit = true;
                $scope.IsLoading = true;
                $scope.Model = null;
            };
            $scope.editItem = function (id) {
                if (id != null) {
                    $scope.showactionmenu = false;
                    $scope.showOverlay = false;
                    $scope.activateNode(id);
                    $scope.IsNew = false;
                    $scope.IsEdit = true;
                    $scope.IsLoading = true;
                    $scope.LinkedResources = null;
                    if ($scope.newTranslation != null)
                        $scope.newTranslation.Title = "";
                    controller.CallPutAction($scope.serviceName, "Lock", id, null, function (data) {
                        $scope.Model = data.Data;
                        $scope.BackQueryString = "mId=" + $scope.Model.MenuId;
                        $scope.loadAuthorisation();
                        $scope.showOverlay = false;
                        $scope.calculateAvailableLanguages();
                        if ($scope.Model.LinkedParentWorkingArea && !$scope.Model.LinkedParentWorkingArea.IsMinervaArea) {
                            $scope.WorkingAreaId = $scope.Model.LinkedParentWorkingArea.Id;
                            $scope.WorkingAreaQueryString = "&waId=" + $scope.Model.LinkedParentWorkingArea.Id;
                        }
                        else {
                            $scope.WorkingAreaId = null;
                            $scope.WorkingAreaQueryString = "";
                        }
                    }, function () {
                        MessagesModule.MessagesController.prototype.ShowMessageBox("Do you want to unlock the menu?", MessagesModule.MessageBoxType.YESNO, "UNLOCK MENU", function () {
                            $scope.forceUnlockItem(id, function () { $scope.editItem(id); });
                        });
                    }, $scope.WorkingAreaQueryString);
                }
            };
            $scope.save = function (alternativecallback) {
                $scope.IsLoading = true;
                var i = 0;
                if ($scope.Model != null)
                    if ($scope.newTranslation != null)
                        $scope.newTranslation.Title = "";
                //$scope.calculateMenuProfiles();
                // if is new
                if ($scope.IsNew) {
                    controller.Post($scope.serviceName, $scope.Model, function (data) {
                        if (alternativecallback != null && alternativecallback != undefined) {
                            alternativecallback();
                            return;
                        }
                        $scope.Model = data.Data;
                        $scope.menuId = $scope.Model.MenuId;
                        $scope.BackQueryString = "mId=" + $scope.Model.MenuId;
                        $scope.IsLoading = true;
                        $scope.showOverlay = true;
                        //$scope.getMenuTree();
                        $scope.IsLoading = false;
                        $scope.showOverlay = false;
                        $scope.IsEdit = true;
                        $scope.IsNew = false;
                        $scope.getMenuTree();
                        //$scope.editItem($scope.Model.MenuId);
                        //$scope.calculateAvailableLanguages();
                        //$scope.loadAuthorisation();
                        //$scope.safeApply();
                        //$scope.loadAuthorisation();
                        //$scope.safeApply();
                        //Decoupling merge with rev. 4300
                        //}, function () { $scope.IsLoading = false; });
                    }, function () { $scope.IsLoading = false; }, $scope.WorkingAreaQueryString);
                    //END Decoupling merge with rev. 4300
                }
                else {
                    // if is a menu set the mime type to null
                    controller.Put($scope.serviceName, $scope.Model.MenuId, $scope.Model, function (data) {
                        if (alternativecallback != null && alternativecallback != undefined) {
                            alternativecallback();
                            return;
                        }
                        $scope.Model = data.Data;
                        $scope.menuId = $scope.Model.MenuId;
                        $scope.BackQueryString = "mId=" + $scope.Model.MenuId;
                        $scope.IsLoading = true;
                        $scope.showOverlay = true;
                        //  $scope.getMenuTree();
                        $scope.IsLoading = false;
                        $scope.showOverlay = false;
                        $scope.IsEdit = true;
                        $scope.IsNew = false;
                        $scope.selectIsApplication(false);
                        //  $scope.calculateAvailableLanguages();
                        $scope.getMenuTree();
                        //$scope.loadAuthorisation();
                        $scope.safeApply();
                        /// $scope.editItem($scope.Model.MenuId);
                    }, function () { $scope.IsLoading = false; }, $scope.WorkingAreaQueryString);
                }
            };
            $scope.newMenuItem = function (id) {
                controller.CallGetAction($scope.serviceName, "NewMenuInstance", id, function (data) {
                    $scope.Model = data.Data;
                    $scope.menuId = null;
                    $scope.BackQueryString = null;
                    //controller.CallGetAction("WorkingArea", "GetAvailableWAForCMSMenu", null, function (data: Module.VMResult) {
                    //    $scope.WorkingAreasToAssign = data.Data;
                    //});
                    $scope.loadAuthorisation();
                    $scope.safeApply(function () {
                        $scope.calculateAvailableLanguages();
                        $scope.showactionmenu = false;
                        $scope.showOverlay = false;
                        $scope.IsNew = true;
                        $scope.IsEdit = false;
                        $scope.ShowProfileSelection = $scope.Model.IsApplication;
                        $scope.ShowWASelection = !$scope.Model.IsApplication;
                    });
                }, null, $scope.WorkingAreaQueryString);
            };
            $scope.removeItem = function (id) {
                /*var parentId:string = null;
                if ($scope.Model != null && $scope.Model != null) {
                    parentId = $scope.Model.ParentId;
                }*/
                var x = confirm(controller.GetMessage("CMS_FILESYSTEM_DELETE_CONFIRM"));
                if (x) {
                    $scope.IsLoading = true;
                    $scope.showOverlay = true;
                    controller.Delete($scope.serviceName, id, function (data) {
                        $scope.showactionmenu = false;
                        $scope.showOverlay = false;
                        $scope.menuId = null;
                        /*if (parentId != null)
                            $scope.editItem(parentId);
                        else*/
                        $scope.clearItem();
                        $scope.IsLoading = true;
                        $scope.showOverlay = true;
                        $scope.getMenuTree();
                        $scope.IsLoading = false;
                        $scope.showOverlay = false;
                    }, function () { $scope.IsLoading = false; }, $scope.WorkingAreaQueryString);
                }
            };
            $scope.Move = function (toMove, moveTo, moveMode) {
                $scope.IsLoading = true;
                $scope.showOverlay = true;
                var queryString = '';
                if (toMove != null && moveTo != null && (moveMode != null && moveMode != '')) {
                    queryString = "tmId=" + toMove.data.Id;
                    queryString += "&mtId=" + moveTo.data.Id;
                    queryString += "&mM=" + moveMode;
                    queryString += "&oP=" + toMove.data.Position;
                    queryString += "&rP=" + moveTo.data.Position;
                    queryString += "&opId=" + toMove.data.ParentId;
                    if (moveTo.data.ParentId)
                        queryString += "&npId=" + moveTo.data.ParentId;
                    else
                        queryString += "&npId=" + moveTo.data.Id;
                }
                else
                    queryString = "";
                controller.CallPutAction($scope.serviceName, "Move", null, null, function (data) {
                    $scope.getMenuTree();
                    $scope.IsLoading = false;
                    $scope.showOverlay = false;
                }, function () {
                    $scope.getMenuTree();
                    $scope.IsLoading = false;
                    $scope.showOverlay = false;
                }, queryString + $scope.WorkingAreaQueryString, true);
            };
            $scope.cancel = function () {
                $scope.showactionmenu = false;
                $scope.showOverlay = false;
                if ($scope.subMenuId != null) {
                    $scope.menuId = $scope.subMenuId;
                    $scope.editItem($scope.menuId);
                }
                /*$scope.IsNew = false;
                $scope.IsEdit = false;*/
            };
            $scope.afterReload = function () {
                if ($scope.menuId != null && $scope.menuId != '') {
                    $scope.activateNode($scope.menuId);
                    //$scope.editItem($scope.menuId);
                }
            };
            $scope.RightClick = function (event, data) {
                //show menu
                var tree = eval('$("#menu_tree").fancytree("getTree")');
                var node = tree.getNodeByKey(data);
                $scope.subMenuId = node.data.Id;
                $scope.showactionmenu = true;
                $scope.showOverlay = true;
                $scope.shownew = true;
                $scope.showedit = true;
                $scope.showunlock = false;
                if ($scope.subMenuId == $scope.menuId)
                    $scope.showunlock = true;
                $scope.menuId = node.data.Id;
                $scope.showdelete = false;
                if ((node.data.children == undefined || node.data.children == null) && node.data.WorkingAreaId == null)
                    $scope.showdelete = true;
                $scope.activateNode($scope.subMenuId);
                $scope.menuTopPos = {
                    "top": (event.clientY + 15) + "px",
                    "left": (event.clientX - 55) + "px"
                };
                $scope.safeApply();
            };
            $scope.Click = function (event, data) {
                if (data.arg2.targetType != "expander") {
                    //open detail
                    $scope.IsNew = false;
                    $scope.IsEdit = true;
                    if ($scope.menuId != null)
                        $scope.unlockItem($scope.menuId);
                    $scope.menuId = data.arg2.node.data.Id;
                    $scope.editItem($scope.menuId);
                }
                $scope.showactionmenu = false;
            };
            $scope.visit = function (item, delegate) {
                if (item == null || item.children == null)
                    return;
                var len = item.children.length;
                delegate(item);
                for (var i = 0; i < len; i++) {
                    $scope.visit(item.children[i], delegate);
                }
            };
            $scope.calculateAvailableLanguages = function () {
                if ($scope.Model != null && $scope.Languages != null && $scope.Languages.length > 0) {
                    $scope.AvailableLanguages = new Array();
                    var i = 0;
                    var j = 0;
                    for (i = 0; i < $scope.Languages.length; i++) {
                        var add = true;
                        for (j = 0; j < $scope.Model.Translations.length; j++) {
                            if ($scope.Model.Translations[j].Language != null && $scope.Model.Translations[j].Language.LanguageId == $scope.Languages[i].LanguageId)
                                add = false;
                        }
                        if (add)
                            $scope.AvailableLanguages.splice(0, 0, $scope.Languages[i]);
                    }
                }
            };
            // discard changes and close page and menu form 
            $scope.discardChanges = function () {
                if ($scope.IsEdit && $scope.unlockItem != null) {
                    $scope.unlockItem($scope.menuId);
                }
                if ($scope.urlVars[5] != null && $scope.urlVars[5] != '') {
                    location.href = "/en/admin/cms/menu";
                    return;
                }
                $scope.menuId = null;
                $scope.Model = null;
            };
            $scope.removeTranslationFromList = function (index) {
                $scope.Model.Translations.splice(index, 1);
                $scope.calculateAvailableLanguages();
            };
            $scope.addTranslation = function () {
                if ($scope.newTranslation == null)
                    return;
                $scope.newTranslation.MenuId = $scope.Model.MenuId;
                var i = 0;
                for (i = 0; i < $scope.Languages.length; i++) {
                    if ($scope.Languages[i].LanguageId == $scope.newTranslation.Language.LanguageId) {
                        $scope.newTranslation.Language = $scope.Languages[i];
                        break;
                    }
                }
                if ($scope.Model.Translations == null) {
                    $scope.Model.Translations = new Array($scope.newTranslation);
                    $scope.calculateAvailableLanguages();
                    return;
                }
                if ($scope.Model.Translations.length == 0) {
                    $scope.Model.Translations.splice(-1, 0, $scope.newTranslation);
                    $scope.calculateAvailableLanguages();
                    return;
                }
                var i = 0;
                var removeList = new Array();
                for (i = 0; i < $scope.Model.Translations.length; i++) {
                    if ($scope.Model.Translations[i] == null ||
                        $scope.Model.Translations[i].Title == null ||
                        $scope.Model.Translations[i].Title == '') {
                        removeList.splice(0, 0, i);
                    }
                }
                for (i = 0; i < removeList.length; i++) {
                    $scope.Model.Translations.splice(removeList[i], 1);
                }
                $scope.Model.Translations.splice($scope.Model.Translations.length, 0, $scope.newTranslation);
                $scope.newTranslation = new Module.VMMenuDetailTranslation();
                $scope.calculateAvailableLanguages();
            };
            $scope.loadAuthorisation = function () {
                var authorisedWAId = '&waId=';
                if ($scope.WorkingAreaId != null && $scope.WorkingAreaId != '') {
                    authorisedWAId = authorisedWAId + $scope.WorkingAreaId;
                }
                else {
                    if ($scope.Model != null) {
                        if ($scope.Model.LinkedParentWorkingArea != null && $scope.Model.LinkedParentWorkingArea.Id != null && $scope.Model.LinkedParentWorkingArea.Id != '')
                            authorisedWAId = authorisedWAId + $scope.Model.LinkedParentWorkingArea.Id;
                        else {
                            if ($scope.Model.LinkedWorkingArea != null && $scope.Model.LinkedWorkingArea.Id != null && $scope.Model.LinkedWorkingArea.Id != '')
                                authorisedWAId = authorisedWAId + $scope.Model.LinkedWorkingArea.Id;
                        }
                    }
                }
                var authQS = authorisedWAId + "&area=MENU&mId=" + (($scope.Model != null) ? $scope.Model.MenuId : '');
                controller.CallGetAction("WorkingArea", "GetMyWorkingAreas", null, function (data) {
                    $scope.WorkingAreas = data.Data;
                    $scope.WorkingAreasToAssign = data.Data;
                    if ($scope.WorkingAreas != null && $scope.Model.LinkedRightOrWAList != null) {
                        $scope.WorkingAreas.forEach(function (wa) { wa.isChecked = false; });
                        $scope.WorkingAreas.forEach(function (wa) { $scope.Model.LinkedRightOrWAList.forEach(function (rightOrWA) { if (wa.Id == rightOrWA.Id) {
                            wa.isChecked = true;
                        } }); });
                    }
                }, null, authQS);
                if ($scope.Model != null && $scope.Rights != null && $scope.Model.LinkedRightOrWAList != null) {
                    $scope.Rights.forEach(function (appRight) { appRight.Rights.forEach(function (profile) { profile.isChecked = false; }); });
                    $scope.Rights.forEach(function (appRight) {
                        appRight.Rights.forEach(function (right) {
                            $scope.Model.LinkedRightOrWAList.forEach(function (rightOrWA) {
                                if (right.RightId == rightOrWA.Id) {
                                    right.isChecked = true;
                                }
                            });
                        });
                    });
                }
                $scope.ShowProfileSelection = $scope.Model.IsApplication;
                $scope.ShowWASelection = !$scope.Model.IsApplication;
                $scope.safeApply();
            };
            $scope.unlockItem = function (id) {
                $scope.showactionmenu = false;
                $scope.showOverlay = false;
                $scope.IsLoading = true;
                controller.CallPutAction($scope.serviceName, "Unlock", id, null, function (data) {
                    $scope.showOverlay = false;
                    $scope.IsLoading = false;
                }, function () {
                    $scope.IsLoading = false;
                    $scope.showOverlay = false;
                    MessagesModule.MessagesController.prototype.ShowMessageBox("Unlock Error!", MessagesModule.MessageBoxType.ERROR, "Error");
                }, $scope.WorkingAreaQueryString);
            };
            $scope.forceUnlockItem = function (id, callback) {
                $scope.showactionmenu = false;
                $scope.showOverlay = false;
                $scope.IsLoading = true;
                controller.CallPutAction($scope.serviceName, "ForceUnlock", id, null, function (data) {
                    $scope.showOverlay = false;
                    $scope.IsLoading = false;
                    if (callback != null)
                        callback(id);
                }, function () {
                    $scope.IsLoading = false;
                    $scope.showOverlay = false;
                    MessagesModule.MessagesController.prototype.ShowMessageBox("Unlock Error!", MessagesModule.MessageBoxType.ERROR, "Error");
                }, $scope.WorkingAreaQueryString);
            };
            /**** TO REPLACE WITH WA*/
            $scope.selectDeselectRightOrWA = function (isChecked, id, model, objtype) {
                if (model == null || id == null || isChecked == null || objtype == null)
                    return;
                if (model.LinkedRightOrWAList == null)
                    model.LinkedRightOrWAList = new Array();
                model.IsPublicRight = false;
                model.IsAuthenticatedRight = false;
                if (isChecked) {
                    var item = new Module.Abstract.VMBase();
                    item.Id = id;
                    item.Type = objtype;
                    model.LinkedRightOrWAList.push(item);
                }
                else {
                    model.LinkedRightOrWAList = $.grep(model.LinkedRightOrWAList, function (value) {
                        return value.Id != id;
                    }, false);
                }
                return model;
            };
            $scope.openSearchModal = function () {
                $scope.showModal = true;
                $scope.SearchingText = "";
                $scope.search();
                $scope.safeApply();
            };
            $scope.selectFileSystemCallBack = function (lang, fsId, name, filetypeid, mimetype, alternativeUrlId, waUrlId) {
                if ($scope.Model == null)
                    return;
                $scope.Model.TargetId = fsId;
                $scope.Model.TargetName = name;
                $scope.Model.TargetMimeType = mimetype;
                $scope.Model.WebContentItems = null;
                $scope.showModal = false;
                $scope.safeApply();
            };
            $scope.removeSelectedContent = function () {
                if ($scope.Model == null)
                    return;
                $scope.Model.TargetId = null;
                $scope.Model.TargetName = null;
                $scope.Model.TargetMimeType = null;
                $scope.Model.WebContentItems = null;
                $scope.safeApply();
            };
            $scope.unlockall = function () {
                $scope.IsLoading = true;
                controller.CallPutAction("Menu", "ForceUnlockAll", null, null, function (data) {
                    $scope.IsLoading = false;
                    $scope.showOverlay = false;
                    MessagesModule.MessagesController.prototype.ShowMessageBox("Successfully unlocked", MessagesModule.MessageBoxType.SUCCESS, "");
                }, function () {
                    $scope.IsLoading = false;
                    $scope.showOverlay = false;
                    MessagesModule.MessagesController.prototype.ShowMessageBox("Unlock Error!", MessagesModule.MessageBoxType.ERROR, "Error");
                }, $scope.WorkingAreaQueryString);
            };
            $scope.selectIsApplication = function (refresh) {
                if (refresh === void 0) { refresh = true; }
                if ($scope.WorkingAreas != null) {
                    $scope.WorkingAreas.forEach(function (x) { x.isChecked = false; });
                }
                if ($scope.Rights != null) {
                    $scope.Rights.forEach(function (x) { x.Rights.forEach(function (p) { p.isChecked = false; }); });
                }
                if (refresh) {
                    $scope.ShowProfileSelection = $scope.Model.IsApplication;
                    $scope.ShowWASelection = !$scope.Model.IsApplication;
                    $scope.Model.IsPublicRight = false;
                    $scope.Model.IsAuthenticatedRight = false;
                    $scope.Model.LinkedRightOrWAList = [];
                }
                $scope.safeApply();
            };
            $scope.showLinkedResources = function (fsId) {
                if (fsId != null && fsId != undefined && fsId != 'undefined') {
                    controller.CallGetAction("FileSystem", "GetFileSystemLinkedContentList", fsId, function (data) {
                        if (data.Data == null || data.Data.length == 0)
                            alert("No match was found!");
                        else
                            $scope.LinkedResources = data.Data;
                    }, null, $scope.WorkingAreaQueryString);
                }
            };
            _this.GetCache("TRANSLATEDLANGUAGES", function (data) {
                $scope.Languages = data.Data;
                controller.CallGetAction("Role", "GetCMSProfileApplications", null, function (data) {
                    $scope.Rights = data.Data;
                    $scope.getMenuTree();
                }, null, $scope.WorkingAreaQueryString);
                controller.GetCache("MENU_THEMES", function (data) { $scope.Themes = data.Data; });
            });
            $scope.showModal = false;
            $scope.IsDocumentLibrary = false;
            return _this;
        }
        return MenuManagementController;
    }(ContentResourceSearchModule.ContentSearchResource));
    CMSModule.MenuManagementController = MenuManagementController;
})(CMSModule || (CMSModule = {}));
angular.module('minervaApp').controller("CMSModule.MenuManagementController", ["$scope", "$http", "$timeout", CMSModule.MenuManagementController]);
//MenuManagement.js.map;
/*! WebContentController.js */var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var CMSModule;
(function (CMSModule) {
    var WebContentController = /** @class */ (function (_super) {
        __extends(WebContentController, _super);
        function WebContentController($scope, $http, $timeout) {
            var _this = 
            // Initialize base class
            _super.call(this, $scope, $http, $timeout) || this;
            var controller = _this;
            // Load base CRUD methods and properties
            //super($scope, $http, "CMS", "ContentData", false);
            //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * * * * * * * * * * * * * * * * * * 
            // * * * * * * * * * * * * * * * * * * * * *  COPIED FROM CrudBaseController * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
            // * * * * * * * * * * * * * * * * * * * * *  IMPORTANT NOTE: THIS SECTION WAS COPIED FROM BASECRUD BECAUSE THE PAGE NEED THE * * * * * * * * * * * * * * * * * * * * * * * *  * 
            // * * * * * * * * * * * * * * * * * * * * *  SEARCH RESOURCE MODAL FOR THE BANNER OR OTHER IMAGES SELECTION BLOCKS * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * 
            //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * * * * * * * * * * * * * * * * * * 
            $scope.getModel = function (parId, secondParId) {
                if (secondParId === void 0) { secondParId = null; }
                controller.Get($scope.serviceName, parId, secondParId, function (data) {
                    $scope.Model = data.Data;
                    $scope.registerOutFormEvents();
                    if ($scope.getModelCallBack != null)
                        $scope.getModelCallBack($scope.Model);
                }, null, null, $scope.WorkingAreaQueryString);
            };
            // lock method call
            $scope.lockModel = function () {
                controller.CallPutActionByLang($scope.serviceName, "TryLockContent", $scope.webPageId, $scope.SelectedLanguage, null, function (data) {
                    $scope.$watch($scope.serviceName, function (newValue, oldValue) {
                        if ($scope.$eval("mainForm.$invalid")) {
                            $scope.shouldBeSaved = true;
                        }
                    });
                    $scope.IsLockedByMe = true;
                    $scope.Model = data.Data;
                    $scope.registerOutFormEvents();
                    if ($scope.lockModelCallBack != null)
                        $scope.lockModelCallBack();
                }, $scope.lockModelErrorCallBack, $scope.WorkingAreaQueryString);
            };
            // unlock method call
            $scope.unlockModel = function (callback) {
                if (callback === void 0) { callback = null; }
                controller.CallPutActionByLang($scope.serviceName, "TryUnLockContent", $scope.webPageId, $scope.SelectedLanguage, null, function (data) {
                    $scope.IsLockedByMe = false;
                    if (callback != null)
                        callback();
                }, null, $scope.WorkingAreaQueryString);
            };
            // Call a web api method to get a new instance of the current model
            $scope.getNewModelInstance = function (queryString) {
                if (queryString === void 0) { queryString = null; }
                controller.CallGetAction($scope.serviceName, "NewObjectInstance", null, function (data) {
                    $scope.Model = data.Data;
                    $scope.registerOutFormEvents();
                    if ($scope.getNewModelInstanceCallBack != null)
                        $scope.getNewModelInstanceCallBack();
                }, null, queryString + $scope.WorkingAreaQueryString);
            };
            // Call a web api method to get a new instance of the current model start to an exists model
            $scope.getNewModelInstanceFromExistsModel = function (id) {
                controller.CallGetAction($scope.serviceName, "NewObjectInstanceFromExistsModel", id, function (data) {
                    $scope.Model = data.Data;
                    $scope.registerOutFormEvents();
                    if ($scope.getNewModelInstanceFromExistsModelCallBack != null)
                        $scope.getNewModelInstanceFromExistsModelCallBack();
                }, null, $scope.WorkingAreaQueryString);
            };
            // method to associate to a generic save button. With one call the system understand if the action is to edit or to add an item.
            $scope.saveModel = function (id, urlRedirect) {
                if (id === void 0) { id = null; }
                if (urlRedirect === void 0) { urlRedirect = null; }
                if ($scope.IsNew) {
                    if (id != null && id != "") {
                        alert("The model has an identifier, thus it is not a new item.");
                        return;
                    }
                    $scope.addModel(urlRedirect);
                }
                else {
                    if (id == null || id == "") {
                        alert("The model does not have a identifier, thus it is not possible to edit.");
                        return;
                    }
                    $scope.updateModel(id, urlRedirect);
                }
            };
            // method to create a new model in a generic CRUD context  (without customizations)
            $scope.addModel = function (urlRedirect) {
                if (urlRedirect === void 0) { urlRedirect = null; }
                if ($scope.checkMandatoryFields == null) {
                    alert("$scope.checkMandatoryFields is not implemented and is mandatory");
                }
                if ($scope.beforeSaveCallBack != null)
                    $scope.beforeSaveCallBack();
                $scope.checkMandatoryFields(function () {
                    controller.Post($scope.serviceName, $scope.Model, function (data) {
                        $scope.forceExit = true;
                        $scope.wasChanged = false;
                        $scope.mainForm.$dirty = false;
                        $scope.mainForm.$pristine = true;
                        if (urlRedirect != null && urlRedirect != undefined && urlRedirect != '') {
                            controller.RedirectToUrl(urlRedirect);
                        }
                        else {
                            $scope.addModelCallBack(data.Data);
                        }
                    }, null, $scope.AddModelQueryString);
                });
            };
            // method to update the model in a generic CRUD context  (without customizations)
            $scope.updateModel = function (id, urlRedirect) {
                if (urlRedirect === void 0) { urlRedirect = null; }
                if (id == null) {
                    id = $scope.IdModel;
                }
                if ($scope.checkMandatoryFields == null) {
                    alert("$scope.checkMandatoryFields is not implemented and is mandatory");
                }
                // if beforeSaveCallBack is set call it
                if ($scope.beforeSaveCallBack != null)
                    $scope.beforeSaveCallBack();
                $scope.checkMandatoryFields(function () {
                    controller.Put($scope.serviceName, id, $scope.Model, function (data) {
                        $scope.wasChanged = false;
                        $scope.mainForm.$dirty = false;
                        $scope.mainForm.$pristine = true;
                        $scope.shouldBeSaved = false;
                        $scope.forceExit = true;
                        if (urlRedirect != null) {
                            $scope.unlockModel(function () {
                                controller.RedirectToUrl(urlRedirect);
                            });
                        }
                        else {
                            if (data != null && data.Data != null)
                                $scope.Model = data.Data;
                            else
                                $scope.getModel($scope.IdModel, $scope.IdModelVersion);
                            if ($scope.afterSaveCallBack != null) {
                                $scope.afterSaveCallBack();
                            }
                        }
                    }, null, $scope.UpdateModelQueryString);
                });
            };
            // function to manage discard changes button click event
            $scope.discardChanges = function (area, controllerName, action, id, queryString) {
                if (action === void 0) { action = null; }
                if (id === void 0) { id = null; }
                if (queryString === void 0) { queryString = null; }
                var url = controller.CreateUrl($scope.Language, area, controllerName, action, id, queryString);
                if ($scope.mainForm.$pristine) {
                    $scope.forceExit = true;
                    if (id == null)
                        id = $scope.IdModel;
                    // if is locked by the current user
                    if ((!$scope.IsNew || $scope.IsLockedByMe) && id != null)
                        $scope.unlockModel(function () {
                            controller.RedirectToUrl(url);
                        });
                    else
                        controller.RedirectToUrl(url);
                    return;
                }
                MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("MINERVA_DISCARD_QUESTION"), MessagesModule.MessageBoxType.YESNO, "", function () {
                    $scope.forceExit = true;
                    if (id == null)
                        id = $scope.IdModel;
                    // if is locked by the current user
                    if ((!$scope.IsNew || $scope.IsLockedByMe) && id != null)
                        $scope.unlockModel(function () {
                            controller.RedirectToUrl(url);
                        });
                    else
                        controller.RedirectToUrl(url);
                });
            };
            $scope.clone = function (obj) {
                // Handle the 3 simple types, and null or undefined
                if (null == obj || "object" != typeof obj)
                    return obj;
                // Handle Date
                if (obj instanceof Date) {
                    var copy = new Date();
                    copy.setTime(obj.getTime());
                    return copy;
                }
                // Handle Array
                if (obj instanceof Array) {
                    var copy = [];
                    for (var i = 0, len = obj.length; i < len; i++) {
                        copy[i] = $scope.clone(obj[i]);
                    }
                    return copy;
                }
                // Handle Object
                if (obj instanceof Object) {
                    var copy = {};
                    for (var attr in obj) {
                        if (obj.hasOwnProperty(attr))
                            copy[attr] = $scope.clone(obj[attr]);
                    }
                    return copy;
                }
                throw new Error("Unable to copy obj! Its type isn't supported.");
            };
            //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * * * * * * * * * * * * * * * * * * 
            // * * * * * * * * * * * * * * * * * * * * *  END COPIED FROM CrudBaseController * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
            //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * * * * * * * * * * * * * * * * * * 
            // START WEB CONTENT BUSINESS LOGIC
            //super($scope, $http, $timeout);
            $scope.AddModelQueryString = $scope.WorkingAreaQueryString;
            $scope.UpdateModelQueryString = $scope.WorkingAreaQueryString;
            $scope.areaName = "CMS";
            $scope.serviceName = "ContentData";
            // Init content search
            $scope.UploadPartialVisibility = true;
            $scope.UploadFilePermissionVisibility = false;
            $scope.FolderVisibility = true;
            $scope.MimeOption = ContentResourceSearchModule.MimeOptions.Image;
            $scope.MimeOptionsVisibility = false;
            $scope.ContentTypeVisibility = false;
            $scope.NewWebContentVisibility = false;
            $scope.DownloadVisibility = false;
            $scope.DeleteVisibility = false;
            $scope.IsNew = false;
            $scope.IsEdit = false;
            $scope.ShowModal = false;
            $scope.MenuIdBack = controller.GetParameterByName('mId');
            $scope.BackMenuQueryString = "";
            if ($scope.MenuIdBack != null && $scope.MenuIdBack != '')
                $scope.BackMenuQueryString = "&mId=" + $scope.MenuIdBack;
            //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
            // * * * * * * * * * * * * * * * * * * * * *   Base class methods implementation  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
            // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
            $scope.loadPage = function () {
                // get the language from query string
                $scope.SelectedLanguage = controller.GetParameterByName('lId');
                if ($scope.SelectedLanguage == null || $scope.SelectedLanguage == undefined || $scope.SelectedLanguage == "undefined" || $scope.SelectedLanguage == "") {
                    alert("Language is mandatory");
                    window.history.back();
                    return;
                }
                // get the filesystem id from query string
                $scope.fileSystemId = controller.GetParameterByName('fId');
                if ($scope.fileSystemId == null || $scope.fileSystemId == undefined || $scope.fileSystemId == "undefined" || $scope.fileSystemId == "") {
                    alert("File System Id is mandatory");
                    window.history.back();
                    return;
                }
                // get the web page id from query string
                $scope.webPageId = controller.GetParameterByName('wpId');
                if ($scope.webPageId == null || $scope.webPageId == undefined || $scope.webPageId == "undefined" || $scope.webPageId == "") {
                    alert("Web Page Id is mandatory");
                    window.history.back();
                    return;
                }
                controller.CallPutActionByLang($scope.serviceName, "TryLockContent", $scope.webPageId, $scope.SelectedLanguage, null, function (data) {
                    $scope.Model = data.Data;
                    $scope.mainForm.$pristine = true;
                    $scope.mainForm.$dirty = false;
                    // in case of new model
                    if ($scope.Model != null) {
                        $scope.IdModel = $scope.webPageId;
                        $scope.IsNew = false;
                        $scope.IsEdit = true;
                        if ($scope.lockModelCallBack != null)
                            $scope.lockModelCallBack();
                    }
                    else {
                        // get from query string if the page is called by the web page 
                        var calledFromWebPage = controller.GetParameterByName('cfwp');
                        if ($scope.SelectedLanguage == "EN") {
                            // get new instance of content model
                            controller.CallGetActionByLang($scope.serviceName, "NewObjectInstance", $scope.webPageId, null, $scope.SelectedLanguage, function (data) {
                                $scope.Model = data.Data;
                                $scope.IsNew = true;
                                $scope.IsEdit = false;
                            }, null, "langId=" + $scope.SelectedLanguage + $scope.WorkingAreaQueryString);
                        }
                        else {
                            if (calledFromWebPage == "1") {
                                MessagesModule.MessagesController.prototype.ShowMessageBox("Do you want to create a copy from the english version?", MessagesModule.MessageBoxType.YESNO, "COPY TRANSLATION FROM", function () {
                                    controller.CallPutAction($scope.serviceName, "Copy", $scope.webPageId, null, function (data) {
                                        $scope.Model = data.Data;
                                        $scope.IsNew = true;
                                        $scope.IsEdit = false;
                                    }, null, "langFrom=EN&langDest=" + $scope.SelectedLanguage);
                                }, function () {
                                    // get new instance of content model
                                    controller.CallGetActionByLang($scope.serviceName, "NewObjectInstance", $scope.webPageId, null, $scope.SelectedLanguage, function (data) {
                                        $scope.Model = data.Data;
                                        $scope.IsNew = true;
                                        $scope.IsEdit = false;
                                    }, null, "langId=" + $scope.SelectedLanguage + $scope.WorkingAreaQueryString);
                                }, null, null);
                            }
                            else {
                                // create new translation?
                                MessagesModule.MessagesController.prototype.ShowMessageBox(controller.GetMessage("CMS_CREATE_TRANSLATION_QUESTION"), MessagesModule.MessageBoxType.YESNO, "CREATE NEW TRANSLATION", function () {
                                    MessagesModule.MessagesController.prototype.ShowMessageBox("Do you want to create a copy from the english version?", MessagesModule.MessageBoxType.YESNO, "COPY TRANSLATION FROM", function () {
                                        controller.CallPutAction($scope.serviceName, "Copy", $scope.webPageId, null, function (data) {
                                            $scope.Model = data.Data;
                                            $scope.IsNew = true;
                                            $scope.IsEdit = false;
                                        }, null, "langFrom=EN&langDest=" + $scope.SelectedLanguage);
                                    }, function () {
                                        // get new instance of content model
                                        controller.CallGetActionByLang($scope.serviceName, "NewObjectInstance", $scope.webPageId, null, $scope.SelectedLanguage, function (data) {
                                            $scope.Model = data.Data;
                                            $scope.IsNew = true;
                                            $scope.IsEdit = false;
                                        }, null, "langId=" + $scope.SelectedLanguage + $scope.WorkingAreaQueryString);
                                    }, null, null);
                                }, function () {
                                    $scope.wasChanged = false;
                                    $scope.mainForm.$dirty = false;
                                    $scope.mainForm.$pristine = true;
                                    $scope.shouldBeSaved = false;
                                    return window.history.back();
                                    //controller.RedirectToAction($scope.Language, "Admin", "Cms", "WebPageEdit", $scope.fileSystemId, "?wpId=" + $scope.webPageId + $scope.BackMenuQueryString);
                                }, null, null);
                            }
                        }
                    }
                }, function () {
                    // in case of error during the lock process.
                    return window.history.back();
                    //controller.RedirectToAction($scope.Language, "Admin", "Cms", "WebPageEdit", $scope.fileSystemId, "?wpId=" + $scope.webPageId + $scope.BackMenuQueryString);
                }, $scope.WorkingAreaQueryString);
            };
            // change language from the drop down
            $scope.changeLanguage = function () {
                return controller.RedirectToAction($scope.Language, "Admin", "Cms", "WebContentEdit", null, "?fId=" + $scope.fileSystemId + "&wpId=" + $scope.webPageId + "&lId=" + $scope.SelectedLanguage + $scope.BackMenuQueryString);
            };
            $scope.Preview = function () {
                return controller.RedirectToAction($scope.Language, "preview", $scope.Model.WorkingAreaName, $scope.fileSystemId, $scope.webPageId);
            };
            // Implements check super mandatory cmsContent fields function
            $scope.checkMandatoryFields = function (successCallBack) {
                if ($scope.IsEdit) {
                    if ($scope.Model.VersionId == null || $scope.Model.VersionId == "") {
                        alert("Error. The content is probably new but you are in edit mode.");
                        return;
                    }
                }
                if ($scope.IsNew) {
                    if ($scope.Model.VersionId != null && $scope.Model.VersionId != "") {
                        alert("Error. The content is probably in edit mode but you are trying to add as new.");
                        return;
                    }
                }
                successCallBack();
            };
            // callback method called after a new establishment save, to redirect the page in the edit mode
            $scope.addModelCallBack = function (result) {
                $scope.Model.VersionId = result;
                if ($scope.IsNew) {
                    $scope.Model.StatusId = "CMS_DRAFT";
                    $scope.IsNew = false;
                    $scope.IsEdit = true;
                }
                $scope.loadPage();
            };
            // redirect to the cms menu management
            $scope.backToWebPage = function () {
                return controller.RedirectToAction($scope.Language, "Admin", "Cms", "WebPageEdit", $scope.fileSystemId, "?wpId=" + $scope.webPageId + $scope.BackMenuQueryString);
            };
            // callback method called  after a lock
            $scope.lockModelCallBack = function () {
                //keep alive session
                if ($scope.Model.Name == null || $scope.Model.Name == '') {
                    controller.CallGetAction("FileSystem", "GetFileSystemName", $scope.fileSystemId, function (data) {
                        $scope.Model.Name = data.Data;
                    }, null, $scope.WorkingAreaQueryString);
                }
                /*
                var timer = $timeout(function KeepAlive() {
                    $timeout(KeepAlive, 60000);
                    controller.CallGetAction("FileSystem", "KeepAlive", null, null);
                }, 60000);
                */
            };
            // publish and unpublish events
            $scope.publishUnpublish = function (publish) {
                if (publish && $scope.Model.IsPublishesd) {
                    MessagesModule.MessagesController.prototype.ShowMessageBox("Web content is already published", MessagesModule.MessageBoxType.ERROR, "Publishing error", null, null, function () { location.href = location.href; });
                    return;
                }
                $scope.checkMandatoryFields(function () {
                    controller.Post($scope.serviceName, $scope.Model, function (data) {
                        $scope.forceExit = true;
                        controller.CallPutAction($scope.serviceName, "PublishUnpublish", $scope.Model.VersionId, null, function (data) {
                            $scope.Model.StatusId = data.Data;
                            $scope.Model.IsPublished = !$scope.Model.IsPublished;
                            $scope.wasChanged = false;
                            $scope.mainForm.$dirty = false;
                            $scope.mainForm.$pristine = true;
                            $scope.shouldBeSaved = false;
                            $scope.forceExit = false;
                        }, null, $scope.WorkingAreaQueryString);
                    }, null, $scope.AddModelQueryString);
                });
            };
            $scope.saveAsDraft = function () {
                controller.CallPutAction($scope.serviceName, "SaveAsDraft", $scope.Model.VersionId, null, function (data) {
                    $scope.Model.VersionId = data.Data;
                    $scope.Model.StatusId = "CMS_DRAFT";
                    $scope.Model.IsPublished = false;
                    $scope.wasChanged = false;
                    $scope.shouldBeSaved = false;
                    $scope.mainForm.$dirty = false;
                    $scope.mainForm.$pristine = true;
                    $scope.forceExit = false;
                }, null, $scope.AddModelQueryString);
            };
            $scope.deleteModel = function () {
                if ($scope.IsNew || $scope.Model.VersionId == null) {
                    alert("Error. The content cannot be deleted because it is new.");
                    return;
                }
                MessagesModule.MessagesController.prototype.ShowMessageBox("Are you sure you want to delete this content?", MessagesModule.MessageBoxType.YESNO, "CONFIRM DELETE", function () {
                    controller.Delete($scope.serviceName, $scope.Model.VersionId, function (data) {
                        //if ($scope.MenuIdBack != null && $scope.MenuIdBack != '')
                        //    return controller.RedirectToAction($scope.Language, "Admin", "Cms", "menu", $scope.MenuIdBack, "?" + $scope.WorkingAreaQueryString);
                        //else
                        //    return controller.RedirectToAction($scope.Language, "Admin", "Cms", "WebPageEdit", $scope.fileSystemId, "?" + $scope.WorkingAreaQueryString + $scope.BackMenuQueryString);
                        $scope.Model.VersionId = data.Data;
                        $scope.Model.StatusId = "CMS_DELETED";
                        $scope.Model.IsPublished = false;
                        $scope.mainForm.$dirty = false;
                        $scope.mainForm.$pristine = true;
                        $scope.wasChanged = false;
                        $scope.shouldBeSaved = false;
                        $scope.forceExit = false;
                    }, null, $scope.WorkingAreaQueryString);
                });
            };
            $scope.tinyOnInitCallBack = function () {
                $scope.wasChanged = false;
                $scope.safeApply();
            };
            $scope.openSearchModal = function (callerBlock) {
                $scope.ShowModal = true;
                $scope.mainForm.$dirty = true;
                $scope.mainForm.$pristine = false;
                $scope.UploadPartialVisibility = false;
                $scope.UploadFilePermissionVisibility = false;
                $scope.SearchingText = "";
                $scope.SearchResourceForBlock = callerBlock;
                $scope.search();
                $scope.safeApply();
            };
            $scope.selectFileSystemCallBack = function (lang, fsId, name, filetypeid, mimetype, alternativeUrlId, waUrlId) {
                if ($scope.Model == null)
                    return;
                if ($scope.SearchResourceForBlock == "TOP_BANNER") {
                    $scope.Model.ContentBlocks.Content_block[0].Content[0].Url = "/en/admin/cms/getimage/" + fsId + "?1=1" + $scope.WorkingAreaQueryString;
                    $scope.Model.ContentBlocks.Content_block[0].Content[0].Src = waUrlId + "/" + alternativeUrlId;
                    $scope.Model.ContentBlocks.Content_block[0].Content[0].FilesystemId = fsId;
                }
                $scope.ShowModal = false;
                $scope.safeApply();
            };
            $scope.addRightWidgetBlock = function (widgettype) {
                $scope.wasChanged = true;
                $scope.ShowWidgetSelector = false;
                $scope.mainForm.$dirty = true;
                $scope.mainForm.$pristine = false;
                var newItem = new Module.Serializable.Content();
                newItem.Type = "WIDGET";
                newItem.Widget = new Module.Serializable.Widget();
                newItem.Widget.Type = widgettype;
                newItem.Widget.TitleColor = "#000000";
                newItem.Widget.BackgroundColor = null;
                newItem.Widget.TitleBackgroundColor = null;
                switch (widgettype) {
                    case 'RSSFEED':
                        newItem.Widget.NumberofItems = 5;
                        break;
                    case 'EMMFEED':
                        newItem.Widget.NumberofItems = 5;
                        newItem.Widget.Title = 'EMM';
                        newItem.Widget.ShowTitle = true;
                        newItem.Widget.FeedUrl = 'http://emm.newsbrief.eu/rss?type=category&id=mahb&language=all';
                        break;
                }
                if ($scope.Model.ContentBlocks.Content_block.length == 2) {
                    var blockItem = new Module.Serializable.ContentBlock();
                    blockItem.Id = "3";
                    blockItem.Content = [];
                    $scope.Model.ContentBlocks.Content_block.push(blockItem);
                }
                $scope.Model.ContentBlocks.Content_block[2].Content.push(newItem);
            };
            $scope.ChangeEditor = function () {
                $scope.wasChanged = true;
                $scope.mainForm.$dirty = true;
                $scope.mainForm.$pristine = false;
            };
            $scope.selectWidget = function () {
                $scope.mainForm.$dirty = true;
                $scope.mainForm.$pristine = false;
                $scope.ShowWidgetSelector = true;
            };
            $scope.ClickWidget = function ($event, listItem, item, itemIndex) {
                $scope.showactionmenu = true;
                $scope.showOverlay = true;
                // add to vertical menu position 15 pixel
                var top = $event.pageY - document.body.scrollTop + 15;
                var left = $event.pageX - 200;
                $scope.menuPosition = {
                    "top": top + "px",
                    "left": left + "px"
                };
                $scope.actualItem = item;
                $scope.actualIndex = itemIndex;
                $scope.listItem = listItem;
                $scope.safeApply();
            };
            $scope.cancel = function () {
                $scope.showactionmenu = false;
                $scope.actualItem = null;
                $scope.actualIndex = null;
                $scope.listItem = null;
                $scope.showOverlay = false;
            };
            $scope.editItem = function () {
                $scope.wasChanged = true;
                $scope.mainForm.$dirty = true;
                $scope.mainForm.$pristine = false;
                $scope.typeWidgetEditor = $scope.actualItem.Widget.Type;
                $scope.ShowWidgetEditor = true;
                $scope.showOverlay = false;
                $scope.showactionmenu = false;
            };
            $scope.removeItem = function () {
                $scope.wasChanged = true;
                $scope.mainForm.$dirty = true;
                $scope.mainForm.$pristine = false;
                $scope.listItem.splice($scope.actualIndex, 1);
                $scope.cancel();
            };
            // dashborad statistics sorting function
            var data;
            $scope.sortableWidgets = {
                placeholder: "ui-state-highlight",
                start: function (event, ui) {
                    var id = "#" + ui.item[0].id;
                    var hh = $(id).css("height");
                    $(".ui-state-highlight").css("height", hh);
                    var start_pos = ui.item.index();
                    ui.item.data('start_pos', start_pos);
                    data = $scope.clone($scope.Model.ContentBlocks.Content_block[2].Content);
                },
                update: function (event, ui) {
                    var start_pos = ui.item.data('start_pos');
                    var end_pos = ui.item.index();
                    data.splice(end_pos, 0, data.splice(start_pos, 1)[0]);
                }
            };
            $scope.cancelWidgetProperties = function () {
                $scope.ShowWidgetEditor = false;
            };
            $scope.setWidgetProperties = function () {
                $scope.ShowWidgetEditor = false;
                $scope.Model.ContentBlocks.Content_block[2].Content[$scope.actualIndex] = $scope.actualItem;
            };
            // Load cache data
            _this.GetCache("translatedlanguages", function (data) { $scope.Languages = data.Data; /*$scope.RepAuthCountries = data.Data;*/ });
            $scope.loadPage();
            return _this;
        }
        return WebContentController;
    }(ResourcesModule.ResourcesController));
    CMSModule.WebContentController = WebContentController;
})(CMSModule || (CMSModule = {}));
angular.module('minervaApp').controller("CMSModule.WebContentController", ["$scope", "$http", "$timeout", CMSModule.WebContentController]);
//WebContentController.js.map;
