Ask the user before loading the template picker
This commit is contained in:
parent
684a12ce2e
commit
fc069dac48
@ -129,6 +129,7 @@ define(function () {
|
|||||||
out.saveTemplatePrompt = "Choisir un titre pour ce modèle";
|
out.saveTemplatePrompt = "Choisir un titre pour ce modèle";
|
||||||
out.templateSaved = "Modèle enregistré !";
|
out.templateSaved = "Modèle enregistré !";
|
||||||
out.selectTemplate = "Sélectionner un modèle ou appuyer sur Échap";
|
out.selectTemplate = "Sélectionner un modèle ou appuyer sur Échap";
|
||||||
|
out.useTemplate = "Vous posséder des modèles pour ce type de pad, souhaitez-vous en utiliser un?";
|
||||||
|
|
||||||
out.previewButtonTitle = "Afficher ou cacher la prévisualisation de Markdown";
|
out.previewButtonTitle = "Afficher ou cacher la prévisualisation de Markdown";
|
||||||
|
|
||||||
|
|||||||
@ -131,6 +131,7 @@ define(function () {
|
|||||||
out.saveTemplatePrompt = "Choose a title for the template";
|
out.saveTemplatePrompt = "Choose a title for the template";
|
||||||
out.templateSaved = "Template saved!";
|
out.templateSaved = "Template saved!";
|
||||||
out.selectTemplate = "Select a template or press escape";
|
out.selectTemplate = "Select a template or press escape";
|
||||||
|
out.useTemplate = "You have available templates for that type of pad. Do you want to use one?";
|
||||||
|
|
||||||
out.previewButtonTitle = "Display or hide the Markdown preview mode";
|
out.previewButtonTitle = "Display or hide the Markdown preview mode";
|
||||||
|
|
||||||
|
|||||||
@ -442,12 +442,15 @@ define([
|
|||||||
UI.openTemplatePicker = function (common) {
|
UI.openTemplatePicker = function (common) {
|
||||||
var metadataMgr = common.getMetadataMgr();
|
var metadataMgr = common.getMetadataMgr();
|
||||||
var type = metadataMgr.getMetadataLazy().type;
|
var type = metadataMgr.getMetadataLazy().type;
|
||||||
|
var sframeChan = common.getSframeChannel();
|
||||||
|
|
||||||
|
var onConfirm = function (yes) {
|
||||||
|
if (!yes) { return; }
|
||||||
var first = true; // We can only pick a template once (for a new document)
|
var first = true; // We can only pick a template once (for a new document)
|
||||||
var fileDialogCfg = {
|
var fileDialogCfg = {
|
||||||
onSelect: function (data) {
|
onSelect: function (data) {
|
||||||
if (data.type === type && first) {
|
if (data.type === type && first) {
|
||||||
Cryptpad.addLoadingScreen({hideTips: true});
|
Cryptpad.addLoadingScreen({hideTips: true});
|
||||||
var sframeChan = common.getSframeChannel();
|
|
||||||
sframeChan.query('Q_TEMPLATE_USE', data.href, function () {
|
sframeChan.query('Q_TEMPLATE_USE', data.href, function () {
|
||||||
first = false;
|
first = false;
|
||||||
Cryptpad.removeLoadingScreen();
|
Cryptpad.removeLoadingScreen();
|
||||||
@ -457,12 +460,19 @@ define([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
common.initFilePicker(common, fileDialogCfg);
|
common.initFilePicker(fileDialogCfg);
|
||||||
var pickerCfg = {
|
var pickerCfg = {
|
||||||
types: [type],
|
types: [type],
|
||||||
where: ['template']
|
where: ['template']
|
||||||
};
|
};
|
||||||
common.openFilePicker(common, pickerCfg);
|
common.openFilePicker(pickerCfg);
|
||||||
|
};
|
||||||
|
|
||||||
|
sframeChan.query("Q_TEMPLATE_EXIST", type, function (err, data) {
|
||||||
|
if (data) {
|
||||||
|
Cryptpad.confirm(Messages.useTemplate, onConfirm);
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return UI;
|
return UI;
|
||||||
|
|||||||
@ -297,6 +297,10 @@ define([
|
|||||||
sframeChan.on('Q_TEMPLATE_USE', function (href, cb) {
|
sframeChan.on('Q_TEMPLATE_USE', function (href, cb) {
|
||||||
Cryptpad.useTemplate(href, Cryptget, cb);
|
Cryptpad.useTemplate(href, Cryptget, cb);
|
||||||
});
|
});
|
||||||
|
sframeChan.on('Q_TEMPLATE_EXIST', function (type, cb) {
|
||||||
|
var hasTemplate = Cryptpad.listTemplates(type).length > 0;
|
||||||
|
cb(hasTemplate);
|
||||||
|
});
|
||||||
|
|
||||||
CpNfOuter.start({
|
CpNfOuter.start({
|
||||||
sframeChan: sframeChan,
|
sframeChan: sframeChan,
|
||||||
|
|||||||
@ -104,6 +104,8 @@ define({
|
|||||||
|
|
||||||
// Template picked, replace the content of the pad
|
// Template picked, replace the content of the pad
|
||||||
'Q_TEMPLATE_USE': true,
|
'Q_TEMPLATE_USE': true,
|
||||||
|
// Check if we have template(s) for the selected pad type
|
||||||
|
'Q_TEMPLATE_EXIST': true,
|
||||||
|
|
||||||
// File upload queries and events
|
// File upload queries and events
|
||||||
'Q_UPLOAD_FILE': true,
|
'Q_UPLOAD_FILE': true,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user