zentaomax.ui.js 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. const docListFunction = window.docAppActions['doc-list'];
  2. $.extend(window.docAppActions,
  3. {
  4. 'doc-list': function(info)
  5. {
  6. let actions = docListFunction.call(this, info);
  7. let dropdown = actions ? actions.find(action => action && action.type === 'dropdown') : null;
  8. if(canModifySpace() && hasPriv('create') && dropdown) dropdown.items.splice(1, 0, {icon: 'file-archive', text: getLang('createByTemplate'), command: 'selectTemplate'});
  9. return actions;
  10. }
  11. })
  12. $.extend(window.docAppCommands,
  13. {
  14. selectTemplate: function(_, args)
  15. {
  16. const docApp = getDocApp();
  17. if(!docApp.libList.length) return zui.Modal.alert(getLang('createLibFirst'));
  18. const url = $.createLink('doc', 'selectTemplate');
  19. zui.Modal.open({size: 'lg', url: url, position: 'fit'});
  20. },
  21. openCreateDocModal: function(_, args)
  22. {
  23. setTimeout(() =>
  24. {
  25. const docApp = getDocApp();
  26. docApp.executeCommand('startCreateDoc', [0, args?.[0] ?? 0]);
  27. }, 500);
  28. }
  29. });