198 lines
6.0 KiB
TypeScript
198 lines
6.0 KiB
TypeScript
import { Global } from "../../Core/Globals"
|
|
import { EventManager } from "../../Core/Events"
|
|
import { Ui } from "../../Core/Ui"
|
|
import * as Events from "../../Core/EventDefinitions"
|
|
import { LocalizationManager } from "../../Core/Localization"
|
|
import * as Utility from "../../Core/Utility";
|
|
import { FormValidation } from "../../Core/Forms"
|
|
import * as Models from "../../Common/Models";
|
|
|
|
|
|
class AppUserReportDetailModule {
|
|
private _moduleName = "AppUserReportDetailModule";
|
|
private _component = "#appReportDetailContainer";
|
|
private _global: Global;
|
|
private _eventManager: EventManager;
|
|
private _uiManager: Ui;
|
|
private _localizationMananger: LocalizationManager;
|
|
|
|
private _currentShowModule: string;
|
|
|
|
constructor() {
|
|
this._global = Global.getInstance();
|
|
this._eventManager = EventManager.getInstance();
|
|
this._uiManager = Ui.getInstance();
|
|
this._localizationMananger = LocalizationManager.getInstance();
|
|
this._currentShowModule = "";
|
|
}
|
|
|
|
/**
|
|
* Stellt einen Prefix vor einen Selektor
|
|
* @param selector
|
|
*/
|
|
private prefix(selector: string): string {
|
|
const self = this;
|
|
if ($(`${self._component} ${selector}`).length > 0)
|
|
return `${self._component} ${selector}`;
|
|
return `html ${selector}`;
|
|
}
|
|
|
|
/** Aktualisieren der Status*/
|
|
private updateStatus(): void {
|
|
var self = this;
|
|
|
|
let reportId = $(self.prefix("#Report_Id")).val();
|
|
let reportStatus = $(self.prefix("#Report_Status")).val();
|
|
let reportComment = $(self.prefix("#Report_InternalComment")).val();
|
|
|
|
self._uiManager.blockMainUi();
|
|
$.ajax({
|
|
url: <string>$(self.prefix("#jsUpdateStatusUrl")).val(),
|
|
data: <any>{ id: reportId, status: reportStatus, internalComment: reportComment },
|
|
dataType: "JSON",
|
|
type: "POST",
|
|
success(result) {
|
|
if (result.success) {
|
|
self._uiManager.pageTitleClear(self._component);
|
|
self._eventManager.unSubscribeAll(self._moduleName);
|
|
self._eventManager.publish(Events.AppUserReport.detailsSuccess, result.data);
|
|
} else {
|
|
self._uiManager.showErrorMessage(result.errorMessage);
|
|
}
|
|
},
|
|
error() {
|
|
|
|
},
|
|
complete() {
|
|
self._uiManager.unblockMainUi();
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* sperren
|
|
*/
|
|
private lock(): void {
|
|
var self = this;
|
|
|
|
let reportedUserId = $(self.prefix("#Report_ReportedAppUserId")).val();
|
|
|
|
self._uiManager.blockMainUi();
|
|
$.ajax({
|
|
url: <string>$(self.prefix("#jsLockUrl")).val(),
|
|
data: <any>{ id: reportedUserId },
|
|
dataType: "HTML",
|
|
type: "GET",
|
|
success(data) {
|
|
self._uiManager.showModule("LockAppUserModule", data);
|
|
},
|
|
error() {
|
|
|
|
},
|
|
complete() {
|
|
self._uiManager.unblockMainUi();
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Inhalt Anzeigen
|
|
*/
|
|
private showContent(): void {
|
|
var self = this;
|
|
|
|
let reportId = $(self.prefix("#Report_Id")).val();
|
|
|
|
self._uiManager.blockMainUi();
|
|
$.ajax({
|
|
url: <string>$(self.prefix("#jsShowContentUrl")).val(),
|
|
data: <any>{ id: reportId },
|
|
dataType: "JSON",
|
|
type: "GET",
|
|
success(response) {
|
|
if (response.success) {
|
|
if (response.module) {
|
|
self._currentShowModule = response.module;
|
|
self._uiManager.showModule(self._currentShowModule, response.html);
|
|
}
|
|
}
|
|
},
|
|
error() {
|
|
|
|
},
|
|
complete() {
|
|
self._uiManager.unblockMainUi();
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Bindungen erstellen
|
|
*/
|
|
private setupBindings(): void {
|
|
var self = this;
|
|
|
|
$(self.prefix("#btnSave")).off("click").on("click", function () {
|
|
self.updateStatus();
|
|
});
|
|
|
|
$(self.prefix("#btnCancel")).off("click").on("click", function () {
|
|
self._uiManager.pageTitleClear(self._component);
|
|
self._eventManager.unSubscribeAll(self._moduleName);
|
|
self._eventManager.publish(Events.AppUserReport.detailsCancel);
|
|
});
|
|
|
|
$(self.prefix("#btnLock")).off("click").on("click", function () {
|
|
self.lock();
|
|
});
|
|
|
|
$(self.prefix("#btnShowContent")).off("click").on("click", function () {
|
|
self.showContent();
|
|
});
|
|
|
|
//#region Events
|
|
|
|
self._eventManager.subscribe(Events.AppUser.lockCancel, self._moduleName, function () {
|
|
self._uiManager.hideModule("LockAppUserModule");
|
|
});
|
|
|
|
self._eventManager.subscribe(Events.AppUser.lockSuccess, self._moduleName, function () {
|
|
self._uiManager.hideModule("LockAppUserModule");
|
|
self._uiManager.showInfoMessage(self._localizationMananger.get("Common_User_Locked"), self._localizationMananger.get("Common_Note"), 5000, true);
|
|
});
|
|
|
|
self._eventManager.subscribe(Events.AppUserReport.showCancel, self._moduleName, function () {
|
|
self._uiManager.hideModule(self._currentShowModule);
|
|
});
|
|
|
|
//#endregion
|
|
|
|
$('[data-toggle="tooltip"]').tooltip();
|
|
}
|
|
|
|
/**
|
|
* Aktivieren des Moduls
|
|
*/
|
|
public activate(): void {
|
|
var self = this;
|
|
$.setupValidator();
|
|
$.reinitializeValidator();
|
|
this.setupBindings();
|
|
self._uiManager.pageTitleAdd(self._component, self.prefix("#pageTitleAdd"));
|
|
$.randomAutocompleteValue();
|
|
}
|
|
|
|
/**
|
|
* Initialisieren des Moduls
|
|
*/
|
|
public init(): void {
|
|
if (this._global.appInitialized) {
|
|
appUserReportDetailModule.activate();
|
|
} else {
|
|
setTimeout(() => { this.init() }, 10);
|
|
}
|
|
}
|
|
}
|
|
|
|
let appUserReportDetailModule = new AppUserReportDetailModule();
|
|
appUserReportDetailModule.init(); |