From c2c610b46c3c27513e17aaeb773929b9367d86ab Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 16 Sep 2021 22:13:13 -0700 Subject: [PATCH] msgtplui - Preview Dialog - If there are no examples, show a decent error message Use Case: You edit a msgtpl for which there are no examples. Before: The dialog opens. The dialog doesn't really work, because there are no examples. Rendering attempts yield errors. After: The dialog declines open. A more pointed error is displayed. --- ext/msgtplui/ang/msgtplui/Edit.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ext/msgtplui/ang/msgtplui/Edit.js b/ext/msgtplui/ang/msgtplui/Edit.js index 876d6f9251..670a29b455 100644 --- a/ext/msgtplui/ang/msgtplui/Edit.js +++ b/ext/msgtplui/ang/msgtplui/Edit.js @@ -278,12 +278,13 @@ }).then(function(resp) { console.log('resp',resp); if ((!resp.examples || resp.examples.length === 0) && resp.adhoc) { - resp.examples = [{ - name: 'auto', - title: ts('Empty example'), - workflow: $ctrl.records.main.workflow_name, - data: {modelProps: resp.adhoc[0]} - }]; + // In the future, if Preview dialog allows editing adhoc examples, then we can show the dialog. But for now, it won't work without explicit examples. + crmUiAlert({ + title: ts('Preview unavailable'), + text: ts('Generating a preview for this message requires example data. Please talk to a developer about adding example data for "%1".', {1: $ctrl.records.main.workflow_name}), + type: 'error' + }); + return; } defaults.exampleName = resp.examples.length > 0 ? (resp.examples)[0].name : null; var i = 0; -- 2.25.1