//---------------------------------------------------------------------------------------------
// This file was AUTO-GENERATED by "SPA Views" Xomega.Net generator.
//
// Manual CHANGES to this file WILL BE LOST when the code is regenerated.
//---------------------------------------------------------------------------------------------

import { SalesOrderCriteria } from 'DataObjects/Sales/SalesOrderCriteriaCustomized';
import { SalesOrderList } from 'DataObjects/Sales/SalesOrderList';
import * as router from 'plugins/router';
import { SearchViewModel, ViewParams } from 'xomega';
import * as controls from 'xomega-controls';

class SalesOrderListView extends SearchViewModel {

    constructor() {
        super();
        this.ListObject = new SalesOrderList();
        this.ListObject.CriteriaObject = new SalesOrderCriteria();
    }

    protected getBaseTitle(): string {
        return 'Sales Order List';
    }

    public attached(view, parent) {
        controls.vSplitViewPanel(view);
        if (this.Params[ViewParams.Mode] == ViewParams.ModePopup)
            controls.modalViewPopup(this, view);
        else if (this.Params[ViewParams.Mode] == ViewParams.ModeInline)
            controls.vSplitViewPopup(this, view);
    }

    public permalink() {
        router.navigate('#' + router.activeInstruction().fragment + this.getPermalink());
    }

    protected LinkDetails_Params(data): any {
        let vm = this;
        let params: any = {};
        params["SalesOrderId"] = data.SalesOrderId;
        params[ViewParams.Mode] = ViewParams.ModeInline;
        params[ViewParams.Source] = "LinkDetails";
        return params;
    }

    public LinkDetails_Click(data) {
        if (!this.LinkDetails_Enabled(data)) return;
        let params = this.LinkDetails_Params(data);
        let vm = this;
        this.navigateTo('SalesOrderView', params);
    }

    public LinkDetails_Enabled(data) {
        return true;
    }

    protected LinkNew_Params(): any {
        let vm = this;
        let params: any = {};
        params[ViewParams.Action] = ViewParams.ActionCreate;
        params[ViewParams.Mode] = ViewParams.ModeInline;
        params[ViewParams.Source] = "LinkNew";
        return params;
    }

    public LinkNew_Click() {
        if (!this.LinkNew_Enabled()) return;
        let params = this.LinkNew_Params();
        let vm = this;
        this.navigateTo('SalesOrderView', params);
    }

    public LinkNew_Enabled() {
        return true;
    }
}

export = SalesOrderListView;
