Changeset 0.27.1 (#167)
This commit is contained in:
@@ -1179,6 +1179,36 @@ function _initChatListeners() {
|
||||
if (typeof UI !== 'undefined') UI.renderChannelsSection();
|
||||
});
|
||||
|
||||
// v0.27.0: Workflow stage advanced — refresh stage bar + auto-switch persona
|
||||
Events.on('workflow.advanced', (payload) => {
|
||||
if (!payload) return;
|
||||
const ac = App.activeConversation;
|
||||
if (ac && ac.id === payload.channel_id) {
|
||||
UI.updateWorkflowStageBar();
|
||||
}
|
||||
// Refresh queue sidebar if present
|
||||
if (typeof WorkflowQueue !== 'undefined') WorkflowQueue.refresh();
|
||||
});
|
||||
|
||||
// v0.27.0: Workflow completed — refresh stage bar
|
||||
Events.on('workflow.completed', (payload) => {
|
||||
if (!payload) return;
|
||||
const ac = App.activeConversation;
|
||||
if (ac && ac.id === payload.channel_id) {
|
||||
UI.updateWorkflowStageBar();
|
||||
}
|
||||
if (typeof WorkflowQueue !== 'undefined') WorkflowQueue.refresh();
|
||||
});
|
||||
|
||||
// v0.27.0: Workflow assigned — refresh queue + toast
|
||||
Events.on('workflow.assigned', (payload) => {
|
||||
if (!payload) return;
|
||||
if (payload.assigned_to === (API.user && API.user.id)) {
|
||||
UI.toast('Workflow stage "' + (payload.stage_name || '?') + '" assigned to you', 'info');
|
||||
}
|
||||
if (typeof WorkflowQueue !== 'undefined') WorkflowQueue.refresh();
|
||||
});
|
||||
|
||||
// Close modals on overlay click
|
||||
document.querySelectorAll('.modal-overlay').forEach(overlay => {
|
||||
overlay.addEventListener('click', (e) => {
|
||||
@@ -1186,3 +1216,33 @@ function _initChatListeners() {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// v0.27.0: Advance workflow stage (called from stage bar button)
|
||||
async function advanceWorkflowStage() {
|
||||
var ac = App.activeConversation;
|
||||
if (!ac || ac.type !== 'workflow') return;
|
||||
var confirmed = await showConfirm('Advance to the next stage?', { title: 'Advance Workflow', danger: false, ok: 'Advance' });
|
||||
if (!confirmed) return;
|
||||
try {
|
||||
var resp = await API._post('/api/v1/channels/' + ac.id + '/workflow/advance', {});
|
||||
UI.toast('Advanced to stage: ' + (resp.stage?.name || resp.current_stage), 'success');
|
||||
UI.updateWorkflowStageBar();
|
||||
} catch (e) {
|
||||
UI.toast('Advance failed: ' + (e.message || e), 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// v0.27.0: Reject workflow stage (called from stage bar button)
|
||||
async function rejectWorkflowStage() {
|
||||
var ac = App.activeConversation;
|
||||
if (!ac || ac.type !== 'workflow') return;
|
||||
var reason = await showPrompt({ title: 'Reject Stage', label: 'Reason for rejection:', placeholder: 'Enter reason...', ok: 'Reject' });
|
||||
if (!reason) return;
|
||||
try {
|
||||
var resp = await API._post('/api/v1/channels/' + ac.id + '/workflow/reject', { reason: reason });
|
||||
UI.toast('Rejected to stage ' + resp.current_stage + ': ' + reason, 'warning');
|
||||
UI.updateWorkflowStageBar();
|
||||
} catch (e) {
|
||||
UI.toast('Reject failed: ' + (e.message || e), 'error');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user