348 lines
12 KiB
TypeScript
348 lines
12 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 * as Models from "../../Common/Models";
|
|
import { Query, DataManager, UrlAdaptor } from "@syncfusion/ej2-data";
|
|
import { AutoComplete } from '@syncfusion/ej2-dropdowns';
|
|
import { NumericTextBox } from "@syncfusion/ej2-inputs";
|
|
import { DatePicker, ChangedEventArgs } from "@syncfusion/ej2-calendars";
|
|
|
|
|
|
class DetailsListingCustomerModule {
|
|
private _moduleName = "DetailsListingCustomerModule";
|
|
private _component = "#listingDetailsCustomerContainer";
|
|
private _global: Global;
|
|
private _eventManager: EventManager;
|
|
private _uiManager: Ui;
|
|
private _localizationMananger: LocalizationManager;
|
|
private _tab: Tab;
|
|
private _tabText: Tab;
|
|
|
|
private _startDatePicker: DatePicker;
|
|
private _endDatePicker: DatePicker;
|
|
private _reservedUntilDatePicker: DatePicker;
|
|
private _payedDatePicker: DatePicker;
|
|
|
|
private _branchsAutoComplete: AutoComplete;
|
|
private _countryAutoComplete: AutoComplete;
|
|
private _stateAutoComplete: AutoComplete;
|
|
|
|
private _latNumeric: NumericTextBox;
|
|
private _lngNumeric: NumericTextBox;
|
|
private _radiusNumeric: NumericTextBox;
|
|
|
|
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}`;
|
|
}
|
|
|
|
/**
|
|
* Bindungen erstellen
|
|
*/
|
|
private setupBindings(): void {
|
|
var self = this;
|
|
|
|
$(self.prefix("#btnBack")).off("click").on("click", function () {
|
|
self._uiManager.pageTitleClear(self._component);
|
|
self._eventManager.unSubscribeAll(self._moduleName);
|
|
self._eventManager.publish(Events.Listing.detailsBack);
|
|
});
|
|
|
|
self._tab = new Tab({
|
|
animation: { previous: { effect: "FadeIn", duration: 100 }, next: { effect: "FadeIn", duration: 100 } },
|
|
selecting: (arsg: any) => {
|
|
if (arsg.isSwiped) {
|
|
arsg.cancel = true;
|
|
}
|
|
},
|
|
selected: (args: any) => {
|
|
if (args.selectedIndex === 1) {
|
|
|
|
}
|
|
}
|
|
});
|
|
self._tab.appendTo(self.prefix("#tabContainer"));
|
|
|
|
self._tabText = new Tab({
|
|
animation: { previous: { effect: "FadeIn", duration: 100 }, next: { effect: "FadeIn", duration: 100 } },
|
|
selecting: (arsg: any) => {
|
|
if (arsg.isSwiped) {
|
|
arsg.cancel = true;
|
|
}
|
|
},
|
|
selected: (args: any) => {
|
|
|
|
}
|
|
});
|
|
self._tabText.appendTo(self.prefix("#tabContainerText"));
|
|
|
|
//#region Lookups
|
|
|
|
self._branchsAutoComplete = new AutoComplete({
|
|
dataSource: new DataManager({
|
|
url: <string>$(self.prefix("#jsLookupBranchesUrl")).val(),
|
|
adaptor: new UrlAdaptor(),
|
|
crossDomain: true,
|
|
headers: [{ "X-Requested-With": "XmlHttpRequest" }]
|
|
}),
|
|
showPopupButton: true,
|
|
placeholder: self._localizationMananger.get("Common_Select"),
|
|
fields: { value: "id", text: "name" },
|
|
value: <string>$(self.prefix("#BranchName")).val(),
|
|
change: (e: any) => {
|
|
if (e.itemData === null) {
|
|
$(self.prefix("#BranchId")).val("");
|
|
}
|
|
else if (e.itemData.id === e.itemData.name) {
|
|
//nichts tun
|
|
} else {
|
|
$(self.prefix("#BranchId")).val(e.itemData.id);
|
|
}
|
|
},
|
|
htmlAttributes: { openhelper: "off" },
|
|
open: function () {
|
|
if (this.value !== null && this.text === this.queryString) {
|
|
this.value = null;
|
|
this.htmlAttributes["openhelper"] = "on";
|
|
}
|
|
},
|
|
close: function () {
|
|
if (this.value === null && this.htmlAttributes["openhelper"] === "on") {
|
|
this.showPopup();
|
|
this.htmlAttributes["openhelper"] = "off";
|
|
}
|
|
}
|
|
});
|
|
self._branchsAutoComplete.appendTo(self.prefix("#BranchName"));
|
|
self._branchsAutoComplete.enabled = false;
|
|
|
|
self._countryAutoComplete = new AutoComplete({
|
|
dataSource: new DataManager({
|
|
url: <string>$(self.prefix("#jsLookupCountriesUrl")).val(),
|
|
adaptor: new UrlAdaptor(),
|
|
crossDomain: true,
|
|
headers: [{ "X-Requested-With": "XmlHttpRequest" }]
|
|
}),
|
|
showPopupButton: true,
|
|
placeholder: self._localizationMananger.get("Common_Select"),
|
|
fields: { value: "id", text: "name" },
|
|
value: <string>$(self.prefix("#CountryName")).val(),
|
|
change: (e: any) => {
|
|
var resetState = false;
|
|
if (e.itemData === null) {
|
|
$(self.prefix("#Address_CountryCode")).val("");
|
|
resetState = true;
|
|
}
|
|
else if (e.itemData.id === e.itemData.name) {
|
|
//nichts tun
|
|
resetState = false;
|
|
} else {
|
|
$(self.prefix("#Address_CountryCode")).val(e.itemData.id);
|
|
resetState = true;
|
|
}
|
|
if (resetState) {
|
|
self._stateAutoComplete.value = null;
|
|
self._stateAutoComplete.text = null;
|
|
self._stateAutoComplete.dataSource = new DataManager({ url: <string>$(self.prefix("#jsLookupStatesUrl")).val() + `?countryIso=${$(self.prefix("#Address_CountryCode")).val()}`, adaptor: new UrlAdaptor(), crossDomain: true, headers: [{ "X-Requested-With": "XmlHttpRequest" }] });
|
|
}
|
|
},
|
|
htmlAttributes: { openhelper: "off" },
|
|
open: function () {
|
|
if (this.value !== null && this.text === this.queryString) {
|
|
this.value = null;
|
|
this.htmlAttributes["openhelper"] = "on";
|
|
}
|
|
},
|
|
close: function () {
|
|
if (this.value === null && this.htmlAttributes["openhelper"] === "on") {
|
|
this.showPopup();
|
|
this.htmlAttributes["openhelper"] = "off";
|
|
}
|
|
}
|
|
});
|
|
self._countryAutoComplete.appendTo(self.prefix("#CountryName"));
|
|
self._countryAutoComplete.enabled = false;
|
|
|
|
self._stateAutoComplete = new AutoComplete({
|
|
dataSource: new DataManager({
|
|
url: <string>$(self.prefix("#jsLookupStatesUrl")).val() + `?countryIso=${$(self.prefix("#Address_CountryCode")).val()}`,
|
|
adaptor: new UrlAdaptor(),
|
|
crossDomain: true,
|
|
headers: [{ "X-Requested-With": "XmlHttpRequest" }]
|
|
}),
|
|
showPopupButton: true,
|
|
placeholder: self._localizationMananger.get("Common_Select"),
|
|
fields: { value: "id", text: "name" },
|
|
value: <string>$(self.prefix("#StateName")).val(),
|
|
change: (e: any) => {
|
|
if (e.itemData === null) {
|
|
$(self.prefix("#Address_State")).val("");
|
|
}
|
|
else if (e.itemData.id === e.itemData.name) {
|
|
//nichts tun
|
|
} else {
|
|
$(self.prefix("#Address_State")).val(e.itemData.id);
|
|
}
|
|
},
|
|
htmlAttributes: { openhelper: "off" },
|
|
open: function () {
|
|
if (this.value !== null && this.text === this.queryString) {
|
|
this.value = null;
|
|
this.htmlAttributes["openhelper"] = "on";
|
|
}
|
|
},
|
|
close: function () {
|
|
if (this.value === null && this.htmlAttributes["openhelper"] === "on") {
|
|
this.showPopup();
|
|
this.htmlAttributes["openhelper"] = "off";
|
|
}
|
|
}
|
|
});
|
|
self._stateAutoComplete.appendTo(self.prefix("#StateName"));
|
|
self._stateAutoComplete.enabled = false;
|
|
|
|
//#endregion
|
|
|
|
//#region DatePicker
|
|
|
|
self._startDatePicker = new DatePicker({
|
|
value: new Date(Date.parse(<string>$(self.prefix("#StartDate")).val())),
|
|
readonly: true
|
|
});
|
|
self._startDatePicker.appendTo(self.prefix("#StartDate"));
|
|
|
|
self._endDatePicker = new DatePicker({
|
|
value: new Date(Date.parse(<string>$(self.prefix("#EndDate")).val())),
|
|
readonly: true
|
|
});
|
|
self._endDatePicker.appendTo(self.prefix("#EndDate"));
|
|
|
|
self._reservedUntilDatePicker = new DatePicker({
|
|
value: new Date(Date.parse(<string>$(self.prefix("#ReservedUntil")).val())),
|
|
readonly: true
|
|
});
|
|
self._reservedUntilDatePicker.appendTo(self.prefix("#ReservedUntil"));
|
|
|
|
self._payedDatePicker = new DatePicker({
|
|
value: new Date(Date.parse(<string>$(self.prefix("#PayedDate")).val())),
|
|
readonly: true
|
|
});
|
|
self._payedDatePicker.appendTo(self.prefix("#PayedDate"));
|
|
|
|
//#endregion
|
|
|
|
//#region Numeric
|
|
|
|
self._latNumeric = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#Lat")).val()),
|
|
decimals: 6,
|
|
step: 1,
|
|
min: -90.0,
|
|
max: 90.0,
|
|
format: "n6",
|
|
change: (e: any) => {
|
|
$(self.prefix("#Lat")).val(Globalize.formatNumber(e.value, { minimumFractionDigits: 6 }));
|
|
},
|
|
readonly: true
|
|
});
|
|
self._latNumeric.appendTo(self.prefix("#LatHelper"));
|
|
|
|
self._lngNumeric = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#Lng")).val()),
|
|
decimals: 6,
|
|
step: 1,
|
|
min: -180.0,
|
|
max: 180.0,
|
|
format: "n6",
|
|
change: (e: any) => {
|
|
$(self.prefix("#Lng")).val(Globalize.formatNumber(e.value, { minimumFractionDigits: 6 }));
|
|
},
|
|
readonly: true
|
|
});
|
|
self._lngNumeric.appendTo(self.prefix("#LngHelper"));
|
|
|
|
self._radiusNumeric = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#Radius")).val()),
|
|
decimals: 2,
|
|
step: 1,
|
|
min: 0.0,
|
|
max: 500.0,
|
|
format: "n2",
|
|
change: (e: any) => {
|
|
$(self.prefix("#Radius")).val(Globalize.formatNumber(e.value, { minimumFractionDigits: 2 }));
|
|
},
|
|
readonly: true
|
|
});
|
|
self._radiusNumeric.appendTo(self.prefix("#RadiusHelper"));
|
|
|
|
//#endregion
|
|
|
|
//#region Switches
|
|
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
//#region image
|
|
|
|
|
|
//#endregion
|
|
|
|
//#region ImageUpload für Sprachversionen
|
|
|
|
|
|
//#endregion
|
|
|
|
//#region Events
|
|
|
|
|
|
//#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) {
|
|
detailsListingCustomerModule.activate();
|
|
} else {
|
|
setTimeout(() => { this.init() }, 10);
|
|
}
|
|
}
|
|
}
|
|
|
|
let detailsListingCustomerModule = new DetailsListingCustomerModule();
|
|
detailsListingCustomerModule.init(); |