882 lines
34 KiB
TypeScript
882 lines
34 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 { DropDownTree } from '@syncfusion/ej2-dropdowns';
|
|
import { RichTextEditor, Toolbar, Link, HtmlEditor, QuickToolbar } from "@syncfusion/ej2-richtexteditor";
|
|
import { Uppload, Local, xhrUploader, Crop, Rotate, Flip, Blur, Brightness, Contrast, Grayscale, Saturate } from "uppload";
|
|
import { Switch } from '@syncfusion/ej2-buttons';
|
|
import * as UpploadHelper from "../../Common/UpploadLanguages"
|
|
import ProductType = Models.ProductType;
|
|
import PriceType = Models.PriceType;
|
|
import PriceAliquotType = Models.PriceAliquotType;
|
|
|
|
|
|
class EditProductModule {
|
|
private _moduleName = "EditProductModule";
|
|
private _component = "#productEditContainer";
|
|
private _global: Global;
|
|
private _eventManager: EventManager;
|
|
private _uiManager: Ui;
|
|
private _localizationMananger: LocalizationManager;
|
|
private _tab: Tab;
|
|
private _tabText: Tab;
|
|
private _upploadImage: Uppload;
|
|
|
|
private _upploadImageLanguage: Uppload;
|
|
private _selectedImageLanguage;
|
|
private _categoryDropDownTree: DropDownTree;
|
|
private _categories;
|
|
private _advertisementCategoryAutoComplete: AutoComplete;
|
|
private _branchsAutoComplete: AutoComplete;
|
|
private _taxRatesAutoComplete: AutoComplete;
|
|
private _rteList : Array<RichTextEditor>;
|
|
|
|
constructor() {
|
|
this._global = Global.getInstance();
|
|
this._eventManager = EventManager.getInstance();
|
|
this._uiManager = Ui.getInstance();
|
|
this._localizationMananger = LocalizationManager.getInstance();
|
|
this._selectedImageLanguage = "";
|
|
this._categories = [];
|
|
RichTextEditor.Inject(Toolbar, Link, HtmlEditor, QuickToolbar);
|
|
this._rteList = [];
|
|
}
|
|
|
|
/**
|
|
* 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();
|
|
//Sonderfall: Disabled select auf nicht disabled setzen, damit diese auch übertragen werden
|
|
$(self.prefix("select")).removeAttr("disabled");
|
|
|
|
var action = $(self.prefix("#frmEditProduct")).attr("action");
|
|
var data = $(self.prefix("#frmEditProduct")).serialize();
|
|
$.post(action, data)
|
|
.done(result => {
|
|
if (result.success) {
|
|
for (var rte of self._rteList) {
|
|
rte.destroy();
|
|
}
|
|
self._uiManager.pageTitleClear(self._component);
|
|
self._eventManager.unSubscribeAll(self._moduleName);
|
|
self._eventManager.publish(Events.Product.editSuccess, result.data);
|
|
}
|
|
else {
|
|
for (var rte of self._rteList) {
|
|
rte.destroy();
|
|
}
|
|
$(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();
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Laden der Kategorien
|
|
*/
|
|
private loadCategories(): void {
|
|
var self = this;
|
|
self._uiManager.blockMainUi();
|
|
$.ajax({
|
|
url: <string>$(self.prefix("#jsGetCategoryUrl")).val(),
|
|
data: <any>{},
|
|
dataType: "JSON",
|
|
type: "GET",
|
|
success(data) {
|
|
self._categories = data;
|
|
self._categoryDropDownTree = new DropDownTree({
|
|
fields: { dataSource: self._categories, value: "id", text: "name", child: "children" },
|
|
placeholder: self._localizationMananger.get("Common_Select"),
|
|
showClearButton: false,
|
|
change: (e: any) => {
|
|
var selectedValue = parseInt(e.value[0]);
|
|
if (selectedValue === -1) {
|
|
$(self.prefix("#ProductCategoryId")).val("");
|
|
} else {
|
|
$(self.prefix("#ProductCategoryId")).val(selectedValue);
|
|
}
|
|
},
|
|
dataBound: () => {
|
|
self._categoryDropDownTree.value = [<string>$(self.prefix("#ProductCategoryId")).val().toString()];
|
|
}
|
|
});
|
|
self._categoryDropDownTree.appendTo(self.prefix("#ProductCategoryName"));
|
|
self._categoryDropDownTree.showClearButton = false;
|
|
},
|
|
error() {
|
|
|
|
},
|
|
complete() {
|
|
self._uiManager.unblockMainUi();
|
|
}
|
|
});
|
|
}
|
|
|
|
/**Behandeln von Änderungen des Produkttyps */
|
|
private handleProductType(): void {
|
|
var self = this;
|
|
|
|
var productType = <ProductType>parseInt($(self.prefix("#ProductType")).val().toString());
|
|
|
|
$(self.prefix("#PriceType")).removeAttr("disabled");
|
|
$(self.prefix("#PriceType option")).removeAttr("disabled");
|
|
|
|
if (productType === ProductType.Physical || productType === ProductType.Download) {
|
|
$(self.prefix("#PriceType")).val(PriceType.Piece);
|
|
$(self.prefix("#PriceType")).attr("disabled", "disabled");
|
|
}
|
|
else if (productType === ProductType.Banner) {
|
|
$(self.prefix("#PriceType")).val(PriceType.View);
|
|
$(self.prefix("#PriceType")).attr("disabled", "disabled");
|
|
} else {
|
|
var priceType = <PriceType>parseInt($(self.prefix("#PriceType")).val().toString());
|
|
if (priceType === PriceType.Piece || priceType === PriceType.View) {
|
|
$(self.prefix("#PriceType")).val(PriceType.Year);
|
|
}
|
|
$(self.prefix(`#PriceType option[value="${PriceType.View}"]`)).attr("disabled", "disabled");
|
|
$(self.prefix(`#PriceType option[value="${PriceType.Piece}"]`)).attr("disabled", "disabled");
|
|
}
|
|
|
|
self.handlePriceType();
|
|
self.handleListingType();
|
|
self.handleAdvertisementCategory();
|
|
self.handleBanner();
|
|
self.handlePin();
|
|
}
|
|
|
|
|
|
/**Ein- und ausblenden des Listungs-Typs je nach Produkt */
|
|
private handleListingType(): void {
|
|
var self = this;
|
|
var productType = <ProductType>parseInt($(self.prefix("#ProductType")).val().toString());
|
|
if (productType === ProductType.Listing) {
|
|
$(self.prefix("#col_listingType")).show();
|
|
} else {
|
|
$(self.prefix("#col_listingType")).hide();
|
|
}
|
|
}
|
|
|
|
/**Ein- und ausblenden der Rubrik je nach Produkt */
|
|
private handleAdvertisementCategory(): void {
|
|
var self = this;
|
|
$(self.prefix("#col_advertisementCategoryId")).hide();
|
|
$(self.prefix("#col_branchId")).hide();
|
|
|
|
var productType = <ProductType>parseInt($(self.prefix("#ProductType")).val().toString());
|
|
if (productType === ProductType.Listing) {
|
|
$(self.prefix("#col_branchId")).show();
|
|
}
|
|
else if(productType === ProductType.Advertisement){
|
|
$(self.prefix("#col_advertisementCategoryId")).show();
|
|
}
|
|
}
|
|
|
|
/**Ein- und ausblenden der Bannereinstellungen je nach Produkt */
|
|
private handleBanner(): void {
|
|
var self = this;
|
|
var productType = <ProductType>parseInt($(self.prefix("#ProductType")).val().toString());
|
|
if (productType === ProductType.Banner) {
|
|
$(self.prefix("#row_banner")).show();
|
|
$(self.prefix("#row_price2")).show();
|
|
} else {
|
|
$(self.prefix("#row_banner")).hide();
|
|
$(self.prefix("#row_price2")).hide();
|
|
}
|
|
}
|
|
|
|
/**Ein- und ausblenden der Pin-Einstellungen je nach Produkt */
|
|
private handlePin(): void {
|
|
var self = this;
|
|
var productType = <ProductType>parseInt($(self.prefix("#ProductType")).val().toString());
|
|
if (productType === ProductType.Pin) {
|
|
$(self.prefix("#row_pin")).show();
|
|
} else {
|
|
$(self.prefix("#row_pin")).hide();
|
|
}
|
|
}
|
|
|
|
/**Einstellungen je nach Preis-Typ */
|
|
private handlePriceType(): void {
|
|
var self = this;
|
|
|
|
var priceType = <PriceType>parseInt($(self.prefix("#PriceType")).val().toString());
|
|
if (priceType === PriceType.Piece) {
|
|
$(self.prefix("#PriceAliquotType")).val(1);
|
|
$(self.prefix("#ProductStartType")).val(1);
|
|
$(self.prefix("#PriceAliquotType")).attr("disabled", "disabled");
|
|
$(self.prefix("#ProductStartType")).attr("disabled", "disabled");
|
|
}
|
|
else if (priceType === PriceType.View) {
|
|
$(self.prefix("#PriceAliquotType")).val(1);
|
|
$(self.prefix("#PriceAliquotType")).attr("disabled", "disabled");
|
|
$(self.prefix("#ProductStartType")).removeAttr("disabled");
|
|
}
|
|
else {
|
|
$(self.prefix("#PriceAliquotType")).removeAttr("disabled");
|
|
$(self.prefix("#ProductStartType")).removeAttr("disabled");
|
|
$(self.prefix("#PriceAliquotType option")).removeAttr("disabled");
|
|
if (priceType === PriceType.Month) {
|
|
$(self.prefix("#PriceAliquotType")).val(PriceAliquotType.None);
|
|
$(self.prefix(`#PriceAliquotType option[value="${PriceAliquotType.Month}"]`)).attr("disabled", "disabled");
|
|
}
|
|
if (priceType === PriceType.Day) {
|
|
$(self.prefix("#PriceAliquotType")).val(PriceAliquotType.None);
|
|
$(self.prefix(`#PriceAliquotType option[value="${PriceAliquotType.Day}"]`)).attr("disabled", "disabled");
|
|
$(self.prefix(`#PriceAliquotType option[value="${PriceAliquotType.Month}"]`)).attr("disabled", "disabled");
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Bindungen erstellen
|
|
*/
|
|
private setupBindings(): void {
|
|
var self = this;
|
|
|
|
$(self.prefix("#btnSave")).off("click").on("click", function () {
|
|
FormValidation.getInstance().validateForm(self.prefix("#frmEditProduct"), () => {
|
|
self.save();
|
|
}, () => {
|
|
$.highlightErrors();
|
|
Utility.showErrorTab();
|
|
});
|
|
});
|
|
|
|
$(self.prefix("#btnCancel")).off("click").on("click", function () {
|
|
for (var rte of self._rteList) {
|
|
rte.destroy();
|
|
}
|
|
self._uiManager.pageTitleClear(self._component);
|
|
self._eventManager.unSubscribeAll(self._moduleName);
|
|
self._eventManager.publish(Events.Product.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;
|
|
}
|
|
},
|
|
selected: (args: any) => {
|
|
if (args.selectedIndex === 1) {
|
|
for (var rte of self._rteList) {
|
|
rte.refreshUI();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
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) => {
|
|
for (var rte of self._rteList) {
|
|
rte.refreshUI();
|
|
}
|
|
}
|
|
});
|
|
self._tabText.appendTo(self.prefix("#tabContainerText"));
|
|
|
|
//#region Lookups
|
|
|
|
self._advertisementCategoryAutoComplete = new AutoComplete({
|
|
dataSource: new DataManager({
|
|
url: <string>$(self.prefix("#jsLookupAdvertisementCategoryUrl")).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("#AdvertisementCategoryName")).val(),
|
|
change: (e: any) => {
|
|
if (e.itemData === null) {
|
|
$(self.prefix("#AdvertisementCategoryId")).val("");
|
|
}
|
|
else if (e.itemData.id === e.itemData.name) {
|
|
//nichts tun
|
|
} else {
|
|
$(self.prefix("#AdvertisementCategoryId")).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._advertisementCategoryAutoComplete.appendTo(self.prefix("#AdvertisementCategoryName"));
|
|
|
|
self._taxRatesAutoComplete = new AutoComplete({
|
|
dataSource: new DataManager({
|
|
url: <string>$(self.prefix("#jsLookupTaxRatesUrl")).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("#TaxRateName")).val(),
|
|
change: (e: any) => {
|
|
if (e.itemData === null) {
|
|
$(self.prefix("#TaxRateId")).val("");
|
|
}
|
|
else if (e.itemData.id === e.itemData.name) {
|
|
//nichts tun
|
|
} else {
|
|
$(self.prefix("#TaxRateId")).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._taxRatesAutoComplete.appendTo(self.prefix("#TaxRateName"));
|
|
|
|
self._branchsAutoComplete = new AutoComplete({
|
|
dataSource: new DataManager({
|
|
url: <string>$(self.prefix("#jsLookupBranchesListingsUrl")).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"));
|
|
|
|
//#endregion
|
|
|
|
//#region Numeric
|
|
|
|
let displayOrder = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#DisplayOrder")).val()),
|
|
decimals: 0,
|
|
step: 1,
|
|
min: 0,
|
|
max: 1000,
|
|
format: "n0",
|
|
change: (e: any) => {
|
|
$(self.prefix("#DisplayOrder")).val(Globalize.formatNumber(e.value));
|
|
}
|
|
});
|
|
displayOrder.appendTo(self.prefix("#DisplayOrderHelper"));
|
|
|
|
let price = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#Price")).val()),
|
|
decimals: 4,
|
|
step: 1,
|
|
min: 0,
|
|
max: 100000000,
|
|
format: "n4",
|
|
change: (e: any) => {
|
|
$(self.prefix("#Price")).val(Globalize.formatNumber(e.value, { minimumFractionDigits: 4 }));
|
|
}
|
|
});
|
|
price.appendTo(self.prefix("#PriceHelper"));
|
|
|
|
let oldPrice = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#OldPrice")).val()),
|
|
decimals: 4,
|
|
step: 1,
|
|
min: 0,
|
|
max: 100000000,
|
|
format: "n4",
|
|
change: (e: any) => {
|
|
$(self.prefix("#OldPrice")).val(Globalize.formatNumber(e.value, { minimumFractionDigits: 4 }));
|
|
}
|
|
});
|
|
oldPrice.appendTo(self.prefix("#OldPriceHelper"));
|
|
|
|
let price2 = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#Price2")).val()),
|
|
decimals: 4,
|
|
step: 1,
|
|
min: 0,
|
|
max: 100000000,
|
|
format: "n4",
|
|
change: (e: any) => {
|
|
$(self.prefix("#Price2")).val(Globalize.formatNumber(e.value, { minimumFractionDigits: 4 }));
|
|
}
|
|
});
|
|
price2.appendTo(self.prefix("#Price2Helper"));
|
|
|
|
let oldPrice2 = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#OldPrice2")).val()),
|
|
decimals: 4,
|
|
step: 1,
|
|
min: 0,
|
|
max: 100000000,
|
|
format: "n4",
|
|
change: (e: any) => {
|
|
$(self.prefix("#OldPrice2")).val(Globalize.formatNumber(e.value, { minimumFractionDigits: 4 }));
|
|
}
|
|
});
|
|
oldPrice2.appendTo(self.prefix("#OldPrice2Helper"));
|
|
|
|
let weight = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#Weight")).val()),
|
|
decimals: 2,
|
|
step: 1,
|
|
min: 0,
|
|
max: 100000,
|
|
format: "n2",
|
|
change: (e: any) => {
|
|
$(self.prefix("#Weight")).val(Globalize.formatNumber(e.value, { minimumFractionDigits: 2 }));
|
|
}
|
|
});
|
|
weight.appendTo(self.prefix("#WeightHelper"));
|
|
|
|
let length = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#Length")).val()),
|
|
decimals: 2,
|
|
step: 1,
|
|
min: 0,
|
|
max: 100000000,
|
|
format: "n2",
|
|
change: (e: any) => {
|
|
$(self.prefix("#Length")).val(Globalize.formatNumber(e.value, { minimumFractionDigits: 2 }));
|
|
}
|
|
});
|
|
length.appendTo(self.prefix("#LengthHelper"));
|
|
|
|
let width = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#Width")).val()),
|
|
decimals: 2,
|
|
step: 1,
|
|
min: 0,
|
|
max: 100000000,
|
|
format: "n2",
|
|
change: (e: any) => {
|
|
$(self.prefix("#Width")).val(Globalize.formatNumber(e.value, { minimumFractionDigits: 2 }));
|
|
}
|
|
});
|
|
width.appendTo(self.prefix("#WidthHelper"));
|
|
|
|
let height = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#Height")).val()),
|
|
decimals: 2,
|
|
step: 1,
|
|
min: 0,
|
|
max: 100000000,
|
|
format: "n2",
|
|
change: (e: any) => {
|
|
$(self.prefix("#Height")).val(Globalize.formatNumber(e.value, { minimumFractionDigits: 2 }));
|
|
}
|
|
});
|
|
height.appendTo(self.prefix("#HeightHelper"));
|
|
|
|
let additionalShippingCharge = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#AdditionalShippingCharge")).val()),
|
|
decimals: 4,
|
|
step: 1,
|
|
min: 0,
|
|
max: 100000,
|
|
format: "n4",
|
|
change: (e: any) => {
|
|
$(self.prefix("#AdditionalShippingCharge")).val(Globalize.formatNumber(e.value, { minimumFractionDigits: 4 }));
|
|
}
|
|
});
|
|
additionalShippingCharge.appendTo(self.prefix("#AdditionalShippingChargeHelper"));
|
|
|
|
let stockQuantity = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#StockQuantity")).val()),
|
|
decimals: 0,
|
|
step: 1,
|
|
min: 0,
|
|
max: 100000000,
|
|
format: "n0",
|
|
change: (e: any) => {
|
|
$(self.prefix("#StockQuantity")).val(Globalize.formatNumber(e.value));
|
|
}
|
|
});
|
|
stockQuantity.appendTo(self.prefix("#StockQuantityHelper"));
|
|
|
|
let notifyAdminForQuantityBelow = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#NotifyAdminForQuantityBelow")).val()),
|
|
decimals: 0,
|
|
step: 1,
|
|
min: 0,
|
|
max: 100000000,
|
|
format: "n0",
|
|
change: (e: any) => {
|
|
$(self.prefix("#NotifyAdminForQuantityBelow")).val(Globalize.formatNumber(e.value));
|
|
}
|
|
});
|
|
notifyAdminForQuantityBelow.appendTo(self.prefix("#NotifyAdminForQuantityBelowHelper"));
|
|
|
|
let orderMinimumQuantity = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#OrderMinimumQuantity")).val()),
|
|
decimals: 0,
|
|
step: 1,
|
|
min: 1,
|
|
max: 100000000,
|
|
format: "n0",
|
|
change: (e: any) => {
|
|
$(self.prefix("#OrderMinimumQuantity")).val(Globalize.formatNumber(e.value));
|
|
}
|
|
});
|
|
orderMinimumQuantity.appendTo(self.prefix("#OrderMinimumQuantityHelper"));
|
|
|
|
let orderMaximumQuantity = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#OrderMaximumQuantity")).val()),
|
|
decimals: 0,
|
|
step: 1,
|
|
min: 1,
|
|
max: 100000000,
|
|
format: "n0",
|
|
change: (e: any) => {
|
|
$(self.prefix("#OrderMaximumQuantity")).val(Globalize.formatNumber(e.value));
|
|
}
|
|
});
|
|
orderMaximumQuantity.appendTo(self.prefix("#OrderMaximumQuantityHelper"));
|
|
|
|
let pinRadius = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#PinRadius")).val()),
|
|
decimals: 2,
|
|
step: 1,
|
|
min: 0.0,
|
|
max: 500.0,
|
|
format: "n2",
|
|
change: (e: any) => {
|
|
$(self.prefix("#PinRadius")).val(Globalize.formatNumber(e.value, { minimumFractionDigits: 2 }));
|
|
}
|
|
});
|
|
pinRadius.appendTo(self.prefix("#PinRadiusHelper"));
|
|
|
|
let pinPercentPerKm = new NumericTextBox({
|
|
value: Globalize.parseNumber($(self.prefix("#PinPercentPerKm")).val()),
|
|
decimals: 2,
|
|
step: 1,
|
|
min: 0,
|
|
max: 100,
|
|
format: "n2",
|
|
change: (e: any) => {
|
|
$(self.prefix("#PinPercentPerKm")).val(Globalize.formatNumber(e.value));
|
|
}
|
|
});
|
|
pinPercentPerKm.appendTo(self.prefix("#PinPercentPerKmHelper"));
|
|
|
|
//let bannerViews = new NumericTextBox({
|
|
// value: Globalize.parseNumber($(self.prefix("#BannerViews")).val()),
|
|
// decimals: 0,
|
|
// step: 1,
|
|
// min: 0,
|
|
// max: 1000000000,
|
|
// format: "n0",
|
|
// change: (e: any) => {
|
|
// $(self.prefix("#BannerViews")).val(Globalize.formatNumber(e.value));
|
|
// }
|
|
//});
|
|
//bannerViews.appendTo(self.prefix("#BannerViewsHelper"));
|
|
|
|
//let bannerRuntime = new NumericTextBox({
|
|
// value: Globalize.parseNumber($(self.prefix("#BannerRuntime")).val()),
|
|
// decimals: 0,
|
|
// step: 1,
|
|
// min: 0,
|
|
// max: 1825,
|
|
// format: "n0",
|
|
// change: (e: any) => {
|
|
// $(self.prefix("#BannerRuntime")).val(Globalize.formatNumber(e.value));
|
|
// }
|
|
//});
|
|
//bannerRuntime.appendTo(self.prefix("#BannerRuntimeHelper"));
|
|
|
|
//#endregion
|
|
|
|
//#region Switches
|
|
|
|
let isTaxExempt = new Switch(
|
|
{ checked: $(self.prefix("#IsTaxExempt")).prop("checked") }
|
|
);
|
|
isTaxExempt.appendTo("#IsTaxExempt");
|
|
|
|
let isShipEnabled = new Switch(
|
|
{ checked: $(self.prefix("#IsShipEnabled")).prop("checked") }
|
|
);
|
|
isShipEnabled.appendTo("#IsShipEnabled");
|
|
|
|
let isFreeShipping = new Switch(
|
|
{ checked: $(self.prefix("#IsFreeShipping")).prop("checked") }
|
|
);
|
|
isFreeShipping.appendTo("#IsFreeShipping");
|
|
|
|
let displayStockAvailability = new Switch(
|
|
{ checked: $(self.prefix("#DisplayStockAvailability")).prop("checked") }
|
|
);
|
|
displayStockAvailability.appendTo("#DisplayStockAvailability");
|
|
|
|
let displayStockQuantity = new Switch(
|
|
{ checked: $(self.prefix("#DisplayStockQuantity")).prop("checked") }
|
|
);
|
|
displayStockQuantity.appendTo("#DisplayStockQuantity");
|
|
|
|
//#endregion
|
|
|
|
//#region RTE
|
|
|
|
$(self.prefix(".rte")).each(function () {
|
|
var id = $(this).prop("id");
|
|
let rte = new RichTextEditor({
|
|
height: 340,
|
|
quickToolbarSettings: {
|
|
image: [
|
|
"Replace", "Align", "Caption", "Remove", "InsertLink", "-", "Display", "AltText", "Dimension"
|
|
],
|
|
link: ["Open", "Edit", "UnLink"]
|
|
},
|
|
toolbarSettings: {
|
|
items: ["Bold", "Italic", "Underline", "StrikeThrough", "FontColor", "|",
|
|
"Formats", "Alignments", "OrderedList", "UnorderedList",
|
|
"Outdent", "Indent", "|",
|
|
"CreateLink", "|", "ClearFormat", "Print",
|
|
"SourceCode", "FullScreen", "|", "Undo", "Redo"]
|
|
}
|
|
});
|
|
rte.appendTo(self.prefix(`#${id}`));
|
|
self._rteList.push(rte);
|
|
});
|
|
|
|
|
|
|
|
//#endregion
|
|
|
|
$(self.prefix("#ProductType")).off("change").on("change", function() {
|
|
self.handleProductType();
|
|
});
|
|
|
|
$(self.prefix("#PriceType")).off("change").on("change", function() {
|
|
self.handlePriceType();
|
|
});
|
|
|
|
//#region image
|
|
|
|
$(self.prefix("#btnUploadImage")).off("click").on("click", function () {
|
|
self._upploadImage.open();
|
|
});
|
|
|
|
$(self.prefix("#btnDeleteImage")).off("click").on("click", function () {
|
|
if ($(self.prefix("#Image")).val())
|
|
self.remove(<string>$(self.prefix("#Image")).val());
|
|
$(self.prefix("#Image")).val("");
|
|
$(self.prefix("#image")).removeAttr("src");
|
|
$(self.prefix("#btnDeleteImage")).hide();
|
|
});
|
|
|
|
var currentLanguage = $("html").attr("lang");
|
|
self._upploadImage = new Uppload({
|
|
lang: UpploadHelper.getLanguage(currentLanguage),
|
|
uploader: xhrUploader({
|
|
endpoint: <string>$(self.prefix("#jsUploadUrl")).val(),
|
|
responseFunction: response => {
|
|
var responseJson = JSON.parse(response);
|
|
$(self.prefix("#Image")).val(responseJson.filename);
|
|
return `/file/temp/${responseJson.filename}`;
|
|
}
|
|
}),
|
|
maxSize: [1280, 720]
|
|
});
|
|
self._upploadImage.use(new Local());
|
|
self._upploadImage.use(new Crop({ aspectRatio: 16 / 9 }));
|
|
self._upploadImage.use(new Rotate());
|
|
self._upploadImage.use(new Flip());
|
|
self._upploadImage.use(<any>[new Blur(), new Brightness(), new Contrast(), new Grayscale(), new Saturate()]);
|
|
|
|
self._upploadImage.on("upload", (url: string) => {
|
|
$(self.prefix("#image")).attr("src", url);
|
|
$(self.prefix("#btnDeleteImage")).show();
|
|
});
|
|
|
|
if ($(self.prefix("#image")).attr("src")) {
|
|
$(self.prefix("#btnDeleteImage")).show();
|
|
}
|
|
|
|
//#endregion
|
|
|
|
//#region ImageUpload für Sprachversionen
|
|
|
|
$(self.prefix(".btn-lang-upload-image")).off("click").on("click", function () {
|
|
self._selectedImageLanguage = $(this).data("language");
|
|
self._upploadImageLanguage.open();
|
|
});
|
|
|
|
$(self.prefix(".btn-lang-delete-image")).off("click").on("click", function () {
|
|
self._selectedImageLanguage = $(this).data("language");
|
|
if ($(self.prefix(`[data-languageimage='${self._selectedImageLanguage}']`)).val())
|
|
self.remove(<string>$(self.prefix(`[data-languageimage='${self._selectedImageLanguage}']`)).val());
|
|
$(self.prefix(`[data-languageimage='${self._selectedImageLanguage}']`)).val("");
|
|
$(self.prefix(`#image_${self._selectedImageLanguage}`)).removeAttr("src");
|
|
$(self.prefix(`#btnDeleteImage_${self._selectedImageLanguage}`)).hide();
|
|
});
|
|
|
|
self._upploadImageLanguage = new Uppload({
|
|
lang: UpploadHelper.getLanguage(currentLanguage),
|
|
uploader: xhrUploader({
|
|
endpoint: <string>$(self.prefix("#jsUploadUrl")).val(),
|
|
responseFunction: response => {
|
|
var responseJson = JSON.parse(response);
|
|
$(self.prefix(`[data-languageimage='${self._selectedImageLanguage}']`)).val(responseJson.filename);
|
|
return `/file/temp/${responseJson.filename}`;
|
|
}
|
|
}),
|
|
maxSize: [1280, 720]
|
|
});
|
|
self._upploadImageLanguage.use(new Local());
|
|
self._upploadImageLanguage.use(new Crop({ aspectRatio: 16 / 9 }));
|
|
self._upploadImageLanguage.use(new Rotate());
|
|
self._upploadImageLanguage.use(new Flip());
|
|
self._upploadImageLanguage.use(<any>[new Blur(), new Brightness(), new Contrast(), new Grayscale(), new Saturate()]);
|
|
|
|
self._upploadImageLanguage.on("upload", (url: string) => {
|
|
$(self.prefix(`#image_${self._selectedImageLanguage}`)).attr("src", url);
|
|
$(self.prefix(`#btnDeleteImage_${self._selectedImageLanguage}`)).show();
|
|
});
|
|
|
|
$(self.prefix("img[data-language]")).each(function() {
|
|
var language = $(this).data("language");
|
|
if ($(this).attr("src")) {
|
|
$(self.prefix(`#btnDeleteImage_${language}`)).show();
|
|
}
|
|
});
|
|
|
|
//#endregion
|
|
|
|
$('[data-toggle="tooltip"]').tooltip();
|
|
}
|
|
|
|
/**
|
|
* Aktivieren des Moduls
|
|
*/
|
|
public activate(): void {
|
|
var self = this;
|
|
$.setupValidator();
|
|
$.reinitializeValidator();
|
|
this.setupBindings();
|
|
self.handleProductType();
|
|
self.loadCategories();
|
|
self._uiManager.pageTitleAdd(self._component, self.prefix("#pageTitleAdd"));
|
|
$.randomAutocompleteValue();
|
|
}
|
|
|
|
/**
|
|
* Initialisieren des Moduls
|
|
*/
|
|
public init(): void {
|
|
if (this._global.appInitialized) {
|
|
editProductModule.activate();
|
|
} else {
|
|
setTimeout(() => { this.init() }, 10);
|
|
}
|
|
}
|
|
}
|
|
|
|
let editProductModule = new EditProductModule();
|
|
editProductModule.init(); |