268 lines
12 KiB
TypeScript
268 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 { InPlaceEditor, ActionEventArgs } from "@syncfusion/ej2-inplace-editor";
|
|
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 { Uppload, Local, xhrUploader, Crop, Rotate, Flip, Blur, Brightness, Contrast, Grayscale, Saturate } from "uppload";
|
|
import { Switch } from '@syncfusion/ej2-buttons';
|
|
import { DatePicker, ChangedEventArgs } from "@syncfusion/ej2-calendars";
|
|
import * as UpploadHelper from "../../Common/UpploadLanguages"
|
|
import OrderStatus = Models.OrderStatus;
|
|
import PaymentStatus = Models.PaymentStatus;
|
|
import ShipmentStatus = Models.ShipmentStatus;
|
|
|
|
|
|
class OrderDetailsModule {
|
|
private _moduleName = "OrderDetailsModule";
|
|
private _component = "#orderDetailsContainer";
|
|
private _global: Global;
|
|
private _eventManager: EventManager;
|
|
private _uiManager: Ui;
|
|
private _localizationMananger: LocalizationManager;
|
|
private _tab: Tab;
|
|
|
|
private _orderStatusList;
|
|
private _orderStatusCurrent: OrderStatus;
|
|
private _orderStatusEditor: InPlaceEditor;
|
|
|
|
private _paymentStatusList;
|
|
private _paymentStatusCurrent: PaymentStatus;
|
|
private _paymentStatusEditor: InPlaceEditor;
|
|
|
|
private _shipmentStatusList;
|
|
private _shipmentStatusCurrent: ShipmentStatus;
|
|
private _shipmentStatusEditor: InPlaceEditor;
|
|
|
|
|
|
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}`;
|
|
}
|
|
|
|
/**Order Status Liste erstellen. Nur Elemente die >= dem aktuellen Status sind, werden hinzugefügt */
|
|
private setupOrderStatusList(): void {
|
|
var self = this;
|
|
|
|
self._orderStatusList = [];
|
|
if (OrderStatus.Pending >= self._orderStatusCurrent)
|
|
self._orderStatusList.push({ value: OrderStatus.Pending, text: self._localizationMananger.get("OrderStatus_Pending") });
|
|
if (OrderStatus.Processing >= self._orderStatusCurrent)
|
|
self._orderStatusList.push({ value: OrderStatus.Processing, text: self._localizationMananger.get("OrderStatus_Processing") });
|
|
if (OrderStatus.Complete >= self._orderStatusCurrent)
|
|
self._orderStatusList.push({ value: OrderStatus.Complete, text: self._localizationMananger.get("OrderStatus_Complete") });
|
|
if (OrderStatus.Cancelled >= self._orderStatusCurrent)
|
|
self._orderStatusList.push({ value: OrderStatus.Cancelled, text: self._localizationMananger.get("OrderStatus_Cancelled") });
|
|
}
|
|
|
|
/**Payment Status Liste erstellen. Nur Elemente die >= dem aktuellen Status sind, werden hinzugefügt */
|
|
private setupPaymentStatusList(): void {
|
|
var self = this;
|
|
|
|
self._paymentStatusList = [];
|
|
if (PaymentStatus.Pending >= self._paymentStatusCurrent)
|
|
self._paymentStatusList.push({ value: PaymentStatus.Pending, text: self._localizationMananger.get("PaymentStatus_Pending") });
|
|
if (PaymentStatus.Authorized >= self._paymentStatusCurrent)
|
|
self._paymentStatusList.push({ value: PaymentStatus.Authorized, text: self._localizationMananger.get("PaymentStatus_Authorized") });
|
|
if (PaymentStatus.Paid >= self._paymentStatusCurrent)
|
|
self._paymentStatusList.push({ value: PaymentStatus.Paid, text: self._localizationMananger.get("PaymentStatus_Paid") });
|
|
//if (PaymentStatus.PartiallyRefunded >= self._paymentStatusCurrent)
|
|
// self._paymentStatusList.push({ value: PaymentStatus.PartiallyRefunded, text: self._localizationMananger.get("PaymentStatus_PartiallyRefunded") });
|
|
if (PaymentStatus.Refunded >= self._paymentStatusCurrent)
|
|
self._paymentStatusList.push({ value: PaymentStatus.Refunded, text: self._localizationMananger.get("PaymentStatus_Refunded") });
|
|
if (PaymentStatus.Voided >= self._paymentStatusCurrent)
|
|
self._paymentStatusList.push({ value: PaymentStatus.Voided, text: self._localizationMananger.get("PaymentStatus_Voided") });
|
|
}
|
|
|
|
/**Shipment Status Liste erstellen. Nur Elemente die >= dem aktuellen Status sind, werden hinzugefügt */
|
|
private setupShipmentStatusList(): void {
|
|
var self = this;
|
|
|
|
self._shipmentStatusList = [];
|
|
if (ShipmentStatus.ShippingNotRequired >= self._shipmentStatusCurrent)
|
|
self._shipmentStatusList.push({ value: ShipmentStatus.ShippingNotRequired, text: self._localizationMananger.get("ShipmentStatus_ShippingNotRequired") });
|
|
if (ShipmentStatus.NotYetShipped >= self._shipmentStatusCurrent)
|
|
self._shipmentStatusList.push({ value: ShipmentStatus.NotYetShipped, text: self._localizationMananger.get("ShipmentStatus_NotYetShipped") });
|
|
if (ShipmentStatus.PartiallyShipped >= self._shipmentStatusCurrent)
|
|
self._shipmentStatusList.push({ value: ShipmentStatus.PartiallyShipped, text: self._localizationMananger.get("ShipmentStatus_PartiallyShipped") });
|
|
if (ShipmentStatus.Shipped >= self._shipmentStatusCurrent)
|
|
self._shipmentStatusList.push({ value: ShipmentStatus.Shipped, text: self._localizationMananger.get("ShipmentStatus_Shipped") });
|
|
if (ShipmentStatus.Delivered >= self._shipmentStatusCurrent)
|
|
self._shipmentStatusList.push({ value: ShipmentStatus.Delivered, text: self._localizationMananger.get("ShipmentStatus_Delivered") });
|
|
}
|
|
|
|
/**
|
|
* 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.Order.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._orderStatusCurrent = OrderStatus[$(self.prefix("#OrderStatus")).val().toString()];
|
|
self._paymentStatusCurrent = PaymentStatus[$(self.prefix("#PaymentStatus")).val().toString()];
|
|
self._shipmentStatusCurrent = ShipmentStatus[$(self.prefix("#ShipmentStatus")).val().toString()];
|
|
|
|
self.setupOrderStatusList();
|
|
self.setupPaymentStatusList();
|
|
self.setupShipmentStatusList();
|
|
|
|
self._orderStatusEditor = new InPlaceEditor({
|
|
mode: "Inline",
|
|
type: "DropDownList",
|
|
name: "OrderStatus",
|
|
value: $(self.prefix("#OrderStatusText")).val(),
|
|
primaryKey: $(self.prefix("#UniqueId")).val().toString(),
|
|
adaptor: "UrlAdaptor",
|
|
url: $(self.prefix("#jsUpdateUrl")).val().toString(),
|
|
model: {
|
|
dataSource: self._orderStatusList,
|
|
fields: { text: "text", value: "value" },
|
|
placeholder: self._localizationMananger.get("Common_Select_Status")
|
|
},
|
|
validationRules: {
|
|
OrderStatus: {required: true}
|
|
},
|
|
actionOnBlur: "Cancel",
|
|
actionSuccess(args: ActionEventArgs) {
|
|
var value = <OrderStatus>parseInt(args.value);
|
|
self._orderStatusCurrent = value;
|
|
self.setupOrderStatusList();
|
|
self._orderStatusEditor.model = {
|
|
dataSource: self._orderStatusList,
|
|
fields: { text: "text", value: "value" },
|
|
placeholder: self._localizationMananger.get("Common_Select_Status")
|
|
};
|
|
}
|
|
});
|
|
self._orderStatusEditor.appendTo(self.prefix("#orderStatusEditor"));
|
|
|
|
self._paymentStatusEditor = new InPlaceEditor({
|
|
mode: "Inline",
|
|
type: "DropDownList",
|
|
name: "PaymentStatus",
|
|
value: $(self.prefix("#PaymentStatusText")).val(),
|
|
primaryKey: $(self.prefix("#UniqueId")).val().toString(),
|
|
adaptor: "UrlAdaptor",
|
|
url: $(self.prefix("#jsUpdateUrl")).val().toString(),
|
|
model: {
|
|
dataSource: self._paymentStatusList,
|
|
fields: { text: "text", value: "value" },
|
|
placeholder: self._localizationMananger.get("Common_Select_Status")
|
|
},
|
|
validationRules: {
|
|
PaymentStatus: { required: true }
|
|
},
|
|
actionOnBlur: "Cancel",
|
|
actionSuccess(args: ActionEventArgs) {
|
|
var value = <PaymentStatus>parseInt(args.value);
|
|
self._paymentStatusCurrent = value;
|
|
self.setupPaymentStatusList();
|
|
self._paymentStatusEditor.model = {
|
|
dataSource: self._paymentStatusList,
|
|
fields: { text: "text", value: "value" },
|
|
placeholder: self._localizationMananger.get("Common_Select_Status")
|
|
};
|
|
}
|
|
});
|
|
self._paymentStatusEditor.appendTo(self.prefix("#paymentStatusEditor"));
|
|
|
|
self._shipmentStatusEditor = new InPlaceEditor({
|
|
mode: "Inline",
|
|
type: "DropDownList",
|
|
name: "ShipmentStatus",
|
|
value: $(self.prefix("#ShipmentStatusText")).val(),
|
|
primaryKey: $(self.prefix("#UniqueId")).val().toString(),
|
|
adaptor: "UrlAdaptor",
|
|
url: $(self.prefix("#jsUpdateUrl")).val().toString(),
|
|
model: {
|
|
dataSource: self._shipmentStatusList,
|
|
fields: { text: "text", value: "value" },
|
|
placeholder: self._localizationMananger.get("Common_Select_Status")
|
|
},
|
|
validationRules: {
|
|
ShipmentStatus: { required: true }
|
|
},
|
|
actionOnBlur: "Cancel",
|
|
actionSuccess(args: ActionEventArgs) {
|
|
var value = <ShipmentStatus>parseInt(args.value);
|
|
self._shipmentStatusCurrent = value;
|
|
self.setupShipmentStatusList();
|
|
self._shipmentStatusEditor.model = {
|
|
dataSource: self._shipmentStatusList,
|
|
fields: { text: "text", value: "value" },
|
|
placeholder: self._localizationMananger.get("Common_Select_Status")
|
|
};
|
|
}
|
|
});
|
|
self._shipmentStatusEditor.appendTo(self.prefix("#shipmentStatusEditor"));
|
|
|
|
|
|
$('[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) {
|
|
orderDetailsModule.activate();
|
|
} else {
|
|
setTimeout(() => { this.init() }, 10);
|
|
}
|
|
}
|
|
}
|
|
|
|
let orderDetailsModule = new OrderDetailsModule();
|
|
orderDetailsModule.init(); |