154 lines
5.1 KiB
TypeScript
154 lines
5.1 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 { Tab } from "@syncfusion/ej2-navigations";
|
|
import * as Utility from "../../Core/Utility";
|
|
import { FormValidation } from "../../Core/Forms"
|
|
import { Switch } from '@syncfusion/ej2-buttons';
|
|
import { DateTimePicker, ChangedEventArgs, DatePicker } from "@syncfusion/ej2-calendars";
|
|
import * as Models from "../../Common/Models";
|
|
|
|
|
|
class EditAppVersionModule {
|
|
private _moduleName = "EditAppVersionModule";
|
|
private _component = "#appVersionEditContainer";
|
|
private _global: Global;
|
|
private _eventManager: EventManager;
|
|
private _uiManager: Ui;
|
|
private _localizationMananger: LocalizationManager;
|
|
private _tab: Tab;
|
|
private _tabText: Tab;
|
|
|
|
private _releaseDatePicker: DateTimePicker;
|
|
|
|
constructor() {
|
|
this._global = Global.getInstance();
|
|
this._eventManager = EventManager.getInstance();
|
|
this._uiManager = Ui.getInstance();
|
|
this._localizationMananger = LocalizationManager.getInstance();
|
|
}
|
|
|
|
/**
|
|
* 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}`;
|
|
}
|
|
|
|
/**
|
|
* Speichern
|
|
*/
|
|
private save(): void {
|
|
var self = this;
|
|
self._uiManager.blockMainUi();
|
|
|
|
var date = self._releaseDatePicker.value;
|
|
var dateUtc = Utility.toUtcDate(date);
|
|
console.log(dateUtc.toTimeString());
|
|
self._releaseDatePicker.value = dateUtc;
|
|
|
|
var action = $(self.prefix("#frmEditAppVersion")).attr("action");
|
|
var data = $(self.prefix("#frmEditAppVersion")).serialize();
|
|
$.post(action, data)
|
|
.done(result => {
|
|
if (result.success) {
|
|
self._uiManager.pageTitleClear(self._component);
|
|
self._eventManager.unSubscribeAll(self._moduleName);
|
|
self._eventManager.publish(Events.AppVersion.editSuccess, result.data);
|
|
}
|
|
else {
|
|
$(self._component).replaceWith(result.html);
|
|
$.highlightErrors();
|
|
Utility.showErrorTab();
|
|
self.activate();
|
|
}
|
|
})
|
|
.fail(result => {
|
|
self._uiManager.showErrorMessage(self._localizationMananger.get("Common_Save_NoSuccess"));
|
|
})
|
|
.always(result => {
|
|
self._uiManager.unblockMainUi();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Bindungen erstellen
|
|
*/
|
|
private setupBindings(): void {
|
|
var self = this;
|
|
|
|
$(self.prefix("#btnSave")).off("click").on("click", function () {
|
|
FormValidation.getInstance().validateForm(self.prefix("#frmEditAppVersion"), () => {
|
|
self.save();
|
|
}, () => {
|
|
$.highlightErrors();
|
|
Utility.showErrorTab();
|
|
});
|
|
});
|
|
|
|
$(self.prefix("#btnCancel")).off("click").on("click", function () {
|
|
self._uiManager.pageTitleClear(self._component);
|
|
self._eventManager.unSubscribeAll(self._moduleName);
|
|
self._eventManager.publish(Events.AppVersion.editCancel);
|
|
});
|
|
|
|
self._tabText = new Tab({
|
|
animation: { previous: { effect: "FadeIn", duration: 100 }, next: { effect: "FadeIn", duration: 100 } },
|
|
selecting: (arsg: any) => {
|
|
if (arsg.isSwiped) {
|
|
arsg.cancel = true;
|
|
}
|
|
}
|
|
});
|
|
self._tabText.appendTo(self.prefix("#tabContainerText"));
|
|
|
|
self._releaseDatePicker = new DateTimePicker({
|
|
value: new Date(Date.parse(<string>$(self.prefix("#ReleaseDate")).val()))
|
|
});
|
|
self._releaseDatePicker.appendTo(self.prefix("#ReleaseDate"));
|
|
|
|
let iscurrent = new Switch(
|
|
{ checked: $(self.prefix("#IsCurrent")).prop("checked") }
|
|
);
|
|
iscurrent.appendTo("#IsCurrent");
|
|
|
|
let isMandatory = new Switch(
|
|
{ checked: $(self.prefix("#IsMandatory")).prop("checked") }
|
|
);
|
|
isMandatory.appendTo("#IsMandatory");
|
|
|
|
$('[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) {
|
|
editAppVersionModule.activate();
|
|
} else {
|
|
setTimeout(() => { this.init() }, 10);
|
|
}
|
|
}
|
|
}
|
|
|
|
let editAppVersionModule = new EditAppVersionModule();
|
|
editAppVersionModule.init(); |