{{ $category }}ShowPopup: function(_item) {
    this.{{ $category }}PopupMode = _item ? 'edit' : 'add';
    this.{{ $category }}PopupItem = _item ? JSON.parse(JSON.stringify(_item)) : JSON.parse(JSON.stringify(this.{{ $category }}Model));
    this.{{ $category }}PopupItem.assigned_pro_uid = '';
    this.{{ $category }}PopupItem.ordering_pro_uid = '';
    if(!this.{{ $category }}PopupItem.comments) this.{{ $category }}PopupItem.comments = [];
    this.comment = '';
    showStagPopup('{{ $category }}-popup', true);
    Vue.nextTick(() => {
        $('#ticketsApp [pro-suggest-initialized]').removeAttr('pro-suggest-initialized');
        initProSuggest();
        if (_item) {
            this.currentCategory = '{{ $category }}';
            this.currentItemUid = _item.uid;
        }
    });
},
{{ $category }}SavePopupItem: function(_autoSave = false) {
    let form = $('#ticketsApp form').first();
    if(!_autoSave) {
        if(!form[0].checkValidity()) {
            form[0].reportValidity();
            return false;
        }
    }
    if(!_autoSave) showMask();
    let payload = {};
    if(this.{{ $category }}PopupMode === 'add') {
        payload.clientUid = '{{ $patient->uid }}';
        payload.category = '{{ $category }}';
        payload.assignedProUid = '{{ $pro->uid  }}';
        payload.managerProUid = '{{ $pro->uid  }}';
        payload.orderingProUid = '{{ $pro->uid  }}';
        payload.initiatingProUid = '{{ $pro->uid  }}';
        payload.data = JSON.stringify(this.{{ $category }}PopupItem.data);
    }
    else {
        payload.uid = this.{{ $category }}PopupItem.uid;
        payload.newData = JSON.stringify(this.{{ $category }}PopupItem.data);
    }
    $.post(
        '/api/ticket/' + (this.{{ $category }}PopupMode === 'add' ? 'create' : 'updateData'),
        payload,
        (_data) => {
            console.log(_data);
            if(!_autoSave) {
                fastReload();
            }
            else {
                this.reloadPopupItem('{{ $category }}');
            }
        },
        'json');
    return false;
},
{{ $category }}SaveComment: function() {
    if(!this.comment) return;
    let comment = {
        pro_id: this.own_pro_id,
        created_at: new Date().toLocaleString(),
        message: this.comment
    };
    if(!this.{{ $category }}PopupItem.data.comments) {
        this.{{ $category }}PopupItem.data.comments = [];
    }
    this.{{ $category }}PopupItem.data.comments.push(comment);
    this.{{ $category }}AutoSave();
},
