Skip to content

Commit

Permalink
fix: шаблоны включены менеджерам и админам
Browse files Browse the repository at this point in the history
  • Loading branch information
popstas committed Apr 27, 2020
1 parent 394a82c commit adfd026
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/tmpls.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ $ = $ || win.$;

const pffTmpls = {
addActions() {
// быстрые ответы
pffTmpls.getTemplates().then((tmpls) => {
pffTmpls.addTextTemplates(tmpls);
});
const PFF = win.PFF;
if(PFF.isManager() || PFF.isAdmin()){
PFF.addTaskBlock('|');
PFF.addTaskBlock('Шаблон', pffTmpls.templateSelect);

// быстрые ответы
pffTmpls.getTemplates().then((tmpls) => {
pffTmpls.addActionTemplates(tmpls);
});
}
},

insertRecord(id, handbookId) {
Expand Down Expand Up @@ -51,7 +57,7 @@ const pffTmpls = {

// update quick templates
pffTmpls.getTemplates().then((tmpls) => {
pffTmpls.addQuickTemplates(tmpls);
pffTmpls.addActionTemplates(tmpls);
});
};

Expand Down Expand Up @@ -243,13 +249,6 @@ const pffTmpls = {
handbookSelectDialog.drawDialog(); // editor.extraHandbookData
},

// быстрые ответы в редактор
addTextTemplates: function(tmpls) {
win.PFF.addTaskBlock('|');
win.PFF.addTaskBlock('Шаблон', pffTmpls.templateSelect);
pffTmpls.addQuickTemplates(tmpls);
},

getQuickTemplates(tmpls) {
const tplsBlock = $('<div class="pff-tpls-content"></div>');
for (let cat in tmpls) {
Expand Down Expand Up @@ -290,7 +289,7 @@ const pffTmpls = {
return newTmplsBlock;
},

addQuickTemplates(tmpls) {
addActionTemplates(tmpls) {
const newTmplsBlock = pffTmpls.getQuickTemplates(tmpls);
const existsTmplsBlock = $('.pff-tmpls');
if(existsTmplsBlock.length > 0){
Expand Down

0 comments on commit adfd026

Please sign in to comment.