690 lines
28 KiB
TypeScript
690 lines
28 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 { MultiSelect } from "@syncfusion/ej2-dropdowns";
|
|
import { DatePicker } from "@syncfusion/ej2-calendars";
|
|
import { NumericTextBox } from "@syncfusion/ej2-inputs";
|
|
import { Uppload, Local, xhrUploader, Crop, Rotate, Flip, Blur, Brightness, Contrast, Grayscale, Saturate } from "uppload";
|
|
import * as UpploadHelper from "../../Common/UpploadLanguages"
|
|
import { Switch } from '@syncfusion/ej2-buttons';
|
|
|
|
class EditCustomerModule {
|
|
private _moduleName = "EditCustomerModule";
|
|
private _component = "#customerEditContainer";
|
|
private _global: Global;
|
|
private _eventManager: EventManager;
|
|
private _uiManager: Ui;
|
|
private _localizationMananger: LocalizationManager;
|
|
private _tab: Tab;
|
|
private _typeAutoComplete: AutoComplete;
|
|
private _branchAutoComplete: AutoComplete;
|
|
private _countryAutoComplete: AutoComplete;
|
|
private _stateAutoComplete: AutoComplete;
|
|
private _languagesMultiselect: MultiSelect;
|
|
private _branchesMultiselect: MultiSelect;
|
|
private _upploadLogo: Uppload;
|
|
|
|
private _mangopayCountryAutoComplete: AutoComplete;
|
|
private _mangopayStateAutoComplete: AutoComplete;
|
|
private _mangopayNationalityAutoComplete: AutoComplete;
|
|
private _mangopayResidenceAutoComplete: AutoComplete;
|
|
private _birthDatePicker: DatePicker;
|
|
|
|
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 action = $(self.prefix("#frmEditCustomer")).attr("action");
|
|
var data = $(self.prefix("#frmEditCustomer")).serialize();
|
|
$.post(action, data)
|
|
.done(result => {
|
|
if (result.success) {
|
|
self._uiManager.pageTitleClear(self._component);
|
|
self._eventManager.unSubscribeAll(self._moduleName);
|
|
self._eventManager.publish(Events.Customer.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();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Löschen des Temporären Files
|
|
* @param filename
|
|
*/
|
|
private remove(filename: string): void {
|
|
var self = this;
|
|
$.ajax({
|
|
url: <string>$(self.prefix("#jsRemoveUrl")).val(),
|
|
data: <any>{ filename },
|
|
dataType: "json",
|
|
type: "POST",
|
|
success(success) {
|
|
if (success)
|
|
self._uiManager.showSuccessMessage(self._localizationMananger.get("Common_Delete_Success"));
|
|
else
|
|
self._uiManager.showErrorMessage(self._localizationMananger.get("Common_Delete_NoSuccess"));
|
|
},
|
|
error(e) {
|
|
self._uiManager.showErrorMessage(self._localizationMananger.get("Common_Delete_NoSuccess"));
|
|
},
|
|
complete() {
|
|
self._uiManager.unblockMainUi();
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Bindungen erstellen
|
|
*/
|
|
private setupBindings(): void {
|
|
var self = this;
|
|
|
|
$(self.prefix("#btnSave")).off("click").on("click", function () {
|
|
FormValidation.getInstance().validateForm(self.prefix("#frmEditCustomer"), () => {
|
|
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.Customer.editCancel);
|
|
});
|
|
|
|
self._tab = new Tab({
|
|
animation: { previous: { effect: "FadeIn", duration: 100 }, next: { effect: "FadeIn", duration: 100 } },
|
|
selecting: (arsg: any) => {
|
|
if (arsg.isSwiped) {
|
|
arsg.cancel = true;
|
|
}
|
|
}
|
|
});
|
|
self._tab.appendTo(self.prefix("#tabContainer"));
|
|
|
|
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);
|
|
$(self.prefix("#frmEditCustomer")).validate().element("#Vat");
|
|
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._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._mangopayCountryAutoComplete = 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("#MangopayCountryName")).val(),
|
|
change: (e: any) => {
|
|
var resetState = false;
|
|
if (e.itemData === null) {
|
|
$(self.prefix("#MangopayAddress_CountryCode")).val("");
|
|
resetState = true;
|
|
}
|
|
else if (e.itemData.id === e.itemData.name) {
|
|
//nichts tun
|
|
resetState = false;
|
|
} else {
|
|
$(self.prefix("#MangopayAddress_CountryCode")).val(e.itemData.id);
|
|
resetState = true;
|
|
}
|
|
if (resetState) {
|
|
self._mangopayStateAutoComplete.value = null;
|
|
self._mangopayStateAutoComplete.text = null;
|
|
self._mangopayStateAutoComplete.dataSource = new DataManager({ url: <string>$(self.prefix("#jsLookupStatesUrl")).val() + `?countryIso=${$(self.prefix("#MangopayAddress_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._mangopayCountryAutoComplete.appendTo(self.prefix("#MangopayCountryName"));
|
|
|
|
self._mangopayStateAutoComplete = new AutoComplete({
|
|
dataSource: new DataManager({
|
|
url: <string>$(self.prefix("#jsLookupStatesUrl")).val() + `?countryIso=${$(self.prefix("#MangopayAddress_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("#MangopayStateName")).val(),
|
|
change: (e: any) => {
|
|
if (e.itemData === null) {
|
|
$(self.prefix("#MangopayAddress_State")).val("");
|
|
}
|
|
else if (e.itemData.id === e.itemData.name) {
|
|
//nichts tun
|
|
} else {
|
|
$(self.prefix("#MangopayAddress_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._mangopayStateAutoComplete.appendTo(self.prefix("#MangopayStateName"));
|
|
|
|
self._mangopayNationalityAutoComplete = 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("#MangopayContactNationalityName")).val(),
|
|
change: (e: any) => {
|
|
var resetState = false;
|
|
if (e.itemData === null) {
|
|
$(self.prefix("#MangopayContactNationality")).val("");
|
|
resetState = true;
|
|
}
|
|
else if (e.itemData.id === e.itemData.name) {
|
|
//nichts tun
|
|
resetState = false;
|
|
} else {
|
|
$(self.prefix("#MangopayContactNationality")).val(e.itemData.id);
|
|
resetState = true;
|
|
}
|
|
if (resetState) {
|
|
|
|
}
|
|
},
|
|
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._mangopayNationalityAutoComplete.appendTo(self.prefix("#MangopayContactNationalityName"));
|
|
|
|
self._mangopayResidenceAutoComplete = 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("#MangopayContactMainResidenceCodeName")).val(),
|
|
change: (e: any) => {
|
|
var resetState = false;
|
|
if (e.itemData === null) {
|
|
$(self.prefix("#MangopayContactMainResidenceCode")).val("");
|
|
resetState = true;
|
|
}
|
|
else if (e.itemData.id === e.itemData.name) {
|
|
//nichts tun
|
|
resetState = false;
|
|
} else {
|
|
$(self.prefix("#MangopayContactMainResidenceCode")).val(e.itemData.id);
|
|
resetState = true;
|
|
}
|
|
if (resetState) {
|
|
|
|
}
|
|
},
|
|
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._mangopayResidenceAutoComplete.appendTo(self.prefix("#MangopayContactMainResidenceCodeName"));
|
|
|
|
self._typeAutoComplete = new AutoComplete({
|
|
dataSource: new DataManager({
|
|
url: <string>$(self.prefix("#jsLookupTypesUrl")).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("#TypeName")).val(),
|
|
change: (e: any) => {
|
|
if (e.itemData === null) {
|
|
$(self.prefix("#TypeId")).val("");
|
|
} else if (e.itemData.id === e.itemData.name) {
|
|
//nichts tun
|
|
} else {
|
|
$(self.prefix("#TypeId")).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._typeAutoComplete.appendTo(self.prefix("#TypeName"));
|
|
|
|
self._branchAutoComplete = 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._branchAutoComplete.appendTo(self.prefix("#BranchName"));
|
|
|
|
self._branchesMultiselect = new MultiSelect({
|
|
dataSource: new DataManager({
|
|
url: <string>$(self.prefix("#jsLookupBranchesListingsUrl")).val(),
|
|
adaptor: new UrlAdaptor(),
|
|
crossDomain: true,
|
|
headers: [{ "X-Requested-With": "XmlHttpRequest" }]
|
|
}),
|
|
fields: { text: "name", value: "id" },
|
|
hideSelectedItem: false,
|
|
mode: "Box",
|
|
placeholder: self._localizationMananger.get("Common_Select"),
|
|
select: (args: any) => {
|
|
var items = [];
|
|
if ($(self.prefix("#BranchesJson")).val().toString().length > 0)
|
|
items = $(self.prefix("#BranchesJson")).val().toString().split(",");
|
|
items.push(args.itemData.id);
|
|
$(self.prefix("#BranchesJson")).val(items.join(","));
|
|
},
|
|
removed: (args: any) => {
|
|
var items = [];
|
|
if ($(self.prefix("#BranchesJson")).val().toString().length > 0)
|
|
items = $(self.prefix("#BranchesJson")).val().toString().split(",");
|
|
let existing = items.find(x => x === args.itemData.id);
|
|
if (existing !== undefined)
|
|
items = items.filter(x => x !== args.itemData.id);
|
|
$(self.prefix("#BranchesJson")).val(items.join(","));
|
|
}
|
|
});
|
|
self._branchesMultiselect.appendTo(self.prefix("#BranchesJsonHelper"));
|
|
if ($(self.prefix("#BranchesJson")).val().toString().length > 0) {
|
|
var items = $(self.prefix("#BranchesJson")).val().toString().split(",");
|
|
self._branchesMultiselect.value = items;
|
|
}
|
|
|
|
self._languagesMultiselect = new MultiSelect({
|
|
dataSource: new DataManager({
|
|
url: <string>$(self.prefix("#jsGetLanguagesUrl")).val(),
|
|
adaptor: new UrlAdaptor(),
|
|
crossDomain: true,
|
|
headers: [{ "X-Requested-With": "XmlHttpRequest" }]
|
|
}),
|
|
fields: { text: "name", value: "iso2" },
|
|
hideSelectedItem: false,
|
|
mode: "Box",
|
|
placeholder: self._localizationMananger.get("Common_Select"),
|
|
select: (args: any) => {
|
|
var items = [];
|
|
if ($(self.prefix("#Languages")).val().toString().length > 0)
|
|
items = $(self.prefix("#Languages")).val().toString().split(",");
|
|
items.push(args.itemData.iso2);
|
|
$(self.prefix("#Languages")).val(items.join(","));
|
|
},
|
|
removed: (args: any) => {
|
|
var items = [];
|
|
if ($(self.prefix("#Languages")).val().toString().length > 0)
|
|
items = $(self.prefix("#Languages")).val().toString().split(",");
|
|
let existing = items.find(x => x === args.itemData.iso2);
|
|
if (existing !== undefined)
|
|
items = items.filter(x => x !== args.itemData.iso2);
|
|
$(self.prefix("#Languages")).val(items.join(","));
|
|
}
|
|
});
|
|
self._languagesMultiselect.appendTo(self.prefix("#LanguagesHelper"));
|
|
if ($(self.prefix("#Languages")).val().toString().length > 0) {
|
|
var items = $(self.prefix("#Languages")).val().toString().split(",");
|
|
self._languagesMultiselect.value = items;
|
|
}
|
|
|
|
let switchIsCompany = new Switch(
|
|
{ checked: $(self.prefix("#IsCompany")).prop("checked") }
|
|
);
|
|
switchIsCompany.appendTo("#IsCompany");
|
|
|
|
let mangopayTermsAccepted = new Switch(
|
|
{ checked: $(self.prefix("#MangopayTermsAccepted")).prop("checked") }
|
|
);
|
|
mangopayTermsAccepted.appendTo("#MangopayTermsAccepted");
|
|
|
|
let paymentOnInvoice = new Switch(
|
|
{ checked: $(self.prefix("#PaymentOnInvoice")).prop("checked") }
|
|
);
|
|
paymentOnInvoice.appendTo("#PaymentOnInvoice");
|
|
|
|
let markupPin = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#MarkupPin")).val()),
|
|
decimals: 2,
|
|
step: 1,
|
|
min: -100,
|
|
max: 100,
|
|
format: "n2",
|
|
change: (e: any) => {
|
|
$(self.prefix("#MarkupPin")).val(Globalize.formatNumber(e.value));
|
|
}
|
|
});
|
|
markupPin.appendTo(self.prefix("#MarkupPinHelper"));
|
|
|
|
let markupListing = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#MarkupListing")).val()),
|
|
decimals: 2,
|
|
step: 1,
|
|
min: -100,
|
|
max: 100,
|
|
format: "n2",
|
|
change: (e: any) => {
|
|
$(self.prefix("#MarkupListing")).val(Globalize.formatNumber(e.value));
|
|
}
|
|
});
|
|
markupListing.appendTo(self.prefix("#MarkupListingHelper"));
|
|
|
|
let markupAdvertisement = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#MarkupAdvertisement")).val()),
|
|
decimals: 2,
|
|
step: 1,
|
|
min: -100,
|
|
max: 100,
|
|
format: "n2",
|
|
change: (e: any) => {
|
|
$(self.prefix("#MarkupAdvertisement")).val(Globalize.formatNumber(e.value));
|
|
}
|
|
});
|
|
markupAdvertisement.appendTo(self.prefix("#MarkupAdvertisementHelper"));
|
|
|
|
let markupBanner = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#MarkupBanner")).val()),
|
|
decimals: 2,
|
|
step: 1,
|
|
min: -100,
|
|
max: 100,
|
|
format: "n2",
|
|
change: (e: any) => {
|
|
$(self.prefix("#MarkupBanner")).val(Globalize.formatNumber(e.value));
|
|
}
|
|
});
|
|
markupBanner.appendTo(self.prefix("#MarkupBannerHelper"));
|
|
|
|
var offset = (new Date().getTimezoneOffset() / 60);
|
|
if (offset < 0) offset *= -1;
|
|
self._birthDatePicker = new DatePicker({
|
|
serverTimezoneOffset: offset,
|
|
value: new Date(Date.parse(<string>$(self.prefix("#MangopayContactBirthdate")).val()))
|
|
});
|
|
self._birthDatePicker.appendTo(self.prefix("#MangopayContactBirthdate"));
|
|
|
|
//#region Logo
|
|
|
|
$(self.prefix("#btnUploadLogo")).off("click").on("click", function () {
|
|
self._upploadLogo.open();
|
|
});
|
|
|
|
$(self.prefix("#btnDeleteLogo")).off("click").on("click", function () {
|
|
if ($(self.prefix("#Logo")).val())
|
|
self.remove(<string>$(self.prefix("#Logo")).val());
|
|
$(self.prefix("#Logo")).val("");
|
|
$(self.prefix("#logoImage")).removeAttr("src");
|
|
$(self.prefix("#btnDeleteLogo")).hide();
|
|
});
|
|
|
|
var currentLanguage = $("html").attr("lang");
|
|
self._upploadLogo = new Uppload({
|
|
lang: UpploadHelper.getLanguage(currentLanguage),
|
|
uploader: xhrUploader({
|
|
endpoint: <string>$(self.prefix("#jsUploadUrl")).val(),
|
|
responseFunction: response => {
|
|
var responseJson = JSON.parse(response);
|
|
$(self.prefix("#Logo")).val(responseJson.filename);
|
|
return `/file/temp/${responseJson.filename}`;
|
|
}
|
|
}),
|
|
maxSize: [1280, 720]
|
|
});
|
|
self._upploadLogo.use(new Local());
|
|
self._upploadLogo.use(new Crop({ aspectRatio: 16 / 9 }));
|
|
self._upploadLogo.use(new Rotate());
|
|
self._upploadLogo.use(new Flip());
|
|
self._upploadLogo.use(<any>[new Blur(), new Brightness(), new Contrast(), new Grayscale(), new Saturate()]);
|
|
|
|
self._upploadLogo.on("upload", (url: string) => {
|
|
$(self.prefix("#logoImage")).attr("src", url);
|
|
$(self.prefix("#btnDeleteLogo")).show();
|
|
});
|
|
|
|
if ($(self.prefix("#logoImage")).attr("src")) {
|
|
$(self.prefix("#btnDeleteLogo")).show();
|
|
}
|
|
|
|
//#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) {
|
|
editCustomerModule.activate();
|
|
} else {
|
|
setTimeout(() => { this.init() }, 10);
|
|
}
|
|
}
|
|
}
|
|
|
|
let editCustomerModule = new EditCustomerModule();
|
|
editCustomerModule.init(); |