mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 19:04:41 -04:00
Proposals
This commit is contained in:
parent
290bf89a6a
commit
1f813c47ca
@ -88,7 +88,7 @@
|
||||
$('#mainForm').submit();
|
||||
}
|
||||
|
||||
function refreshProposal() {
|
||||
function loadTemplate() {
|
||||
var templateId = $('select#proposal_template_id').val();
|
||||
var template = templateMap[templateId];
|
||||
|
||||
@ -96,11 +96,20 @@
|
||||
return;
|
||||
}
|
||||
|
||||
var html = template.html;
|
||||
var html = mergeTemplate(template.html);
|
||||
|
||||
window.grapesjsEditor.setComponents(html);
|
||||
window.grapesjsEditor.setStyle(template.css);
|
||||
}
|
||||
|
||||
function mergeTemplate(html) {
|
||||
var quoteId = $('select#quote_id').val();
|
||||
var quote = quoteMap[quoteId];
|
||||
|
||||
if (quote) {
|
||||
if (!quote) {
|
||||
return html;
|
||||
}
|
||||
|
||||
var regExp = new RegExp(/\$[a-z][\w\.]*/, 'g');
|
||||
var matches = html.match(regExp);
|
||||
|
||||
@ -121,10 +130,8 @@
|
||||
html = html.replace(match, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.grapesjsEditor.setComponents(html);
|
||||
window.grapesjsEditor.setStyle(template.css);
|
||||
return html;
|
||||
}
|
||||
|
||||
$(function() {
|
||||
@ -141,7 +148,7 @@
|
||||
$quoteSelect.val(quote.public_id);
|
||||
setComboboxValue($('.quote-select'), quote.public_id, quote.invoice_number + ' - ' + getClientDisplayName(quote.client));
|
||||
}
|
||||
$quoteSelect.change(refreshProposal);
|
||||
$quoteSelect.change(loadTemplate);
|
||||
|
||||
var templateId = {{ ! empty($templatePublicId) ? $templatePublicId : 0 }};
|
||||
var $proposal_templateSelect = $('select#proposal_template_id');
|
||||
@ -155,11 +162,22 @@
|
||||
var template = templateMap[templateId];
|
||||
setComboboxValue($('.template-select'), template.public_id, template.name);
|
||||
}
|
||||
$proposal_templateSelect.change(refreshProposal);
|
||||
$proposal_templateSelect.change(loadTemplate);
|
||||
})
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@include('proposals.grapesjs', ['entity' => $proposal])
|
||||
@include('proposals.grapesjs', ['entity' => $proposal])
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(function() {
|
||||
grapesjsEditor.on('canvas:drop', function() {
|
||||
var html = mergeTemplate(grapesjsEditor.getHtml());
|
||||
grapesjsEditor.setComponents(html);
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@stop
|
||||
|
Loading…
x
Reference in New Issue
Block a user