Fix for description textarea

This commit is contained in:
Hillel Coren 2016-09-18 22:12:09 +03:00
parent ec963e0823
commit 0d2b1f64f9
2 changed files with 7 additions and 54 deletions

View File

@ -262,8 +262,8 @@
</div> </div>
</td> </td>
<td> <td>
<textarea data-bind="value: wrapped_notes, valueUpdate: 'afterkeydown', attr: {name: 'invoice_items[' + $index() + '][notes]'}" <textarea data-bind="value: notes, valueUpdate: 'afterkeydown', attr: {name: 'invoice_items[' + $index() + '][notes]'}"
rows="1" cols="60" style="resize: vertical" class="form-control word-wrap"></textarea> rows="1" cols="60" style="resize: vertical;height:42px" class="form-control word-wrap"></textarea>
<input type="text" data-bind="value: task_public_id, attr: {name: 'invoice_items[' + $index() + '][task_public_id]'}" style="display: none"/> <input type="text" data-bind="value: task_public_id, attr: {name: 'invoice_items[' + $index() + '][task_public_id]'}" style="display: none"/>
<input type="text" data-bind="value: expense_public_id, attr: {name: 'invoice_items[' + $index() + '][expense_public_id]'}" style="display: none"/> <input type="text" data-bind="value: expense_public_id, attr: {name: 'invoice_items[' + $index() + '][expense_public_id]'}" style="display: none"/>
</td> </td>
@ -340,11 +340,11 @@
<div class="tab-content"> <div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="notes" style="padding-bottom:44px"> <div role="tabpanel" class="tab-pane active" id="notes" style="padding-bottom:44px">
{!! Former::textarea('public_notes')->data_bind("value: wrapped_notes, valueUpdate: 'afterkeydown'") {!! Former::textarea('public_notes')->data_bind("value: public_notes, valueUpdate: 'afterkeydown'")
->label(null)->style('resize: none; width: 500px;')->rows(4) !!} ->label(null)->style('resize: none; width: 500px;')->rows(4) !!}
</div> </div>
<div role="tabpanel" class="tab-pane" id="terms"> <div role="tabpanel" class="tab-pane" id="terms">
{!! Former::textarea('terms')->data_bind("value:wrapped_terms, placeholder: terms_placeholder, valueUpdate: 'afterkeydown'") {!! Former::textarea('terms')->data_bind("value:terms, placeholder: terms_placeholder, valueUpdate: 'afterkeydown'")
->label(false)->style('resize: none; width: 500px')->rows(4) ->label(false)->style('resize: none; width: 500px')->rows(4)
->help('<div class="checkbox"> ->help('<div class="checkbox">
<label> <label>
@ -356,7 +356,7 @@
</div>') !!} </div>') !!}
</div> </div>
<div role="tabpanel" class="tab-pane" id="footer"> <div role="tabpanel" class="tab-pane" id="footer">
{!! Former::textarea('invoice_footer')->data_bind("value:wrapped_footer, placeholder: footer_placeholder, valueUpdate: 'afterkeydown'") {!! Former::textarea('invoice_footer')->data_bind("value:invoice_footer, placeholder: footer_placeholder, valueUpdate: 'afterkeydown'")
->label(false)->style('resize: none; width: 500px')->rows(4) ->label(false)->style('resize: none; width: 500px')->rows(4)
->help('<div class="checkbox"> ->help('<div class="checkbox">
<label> <label>
@ -1108,10 +1108,9 @@
}); });
$('textarea').on('keyup focus', function(e) { $('textarea').on('keyup focus', function(e) {
while($(this).outerHeight() < this.scrollHeight + parseFloat($(this).css("borderTopWidth")) + parseFloat($(this).css("borderBottomWidth"))) { $(this).height(0).height(this.scrollHeight-18);
$(this).height($(this).height()+1);
};
}); });
} }
function createInvoiceModel() { function createInvoiceModel() {

View File

@ -296,40 +296,6 @@ function InvoiceModel(data) {
} }
}) })
self.wrapped_terms = ko.computed({
read: function() {
return this.terms();
},
write: function(value) {
value = wordWrapText(value, 300);
self.terms(value);
},
owner: this
});
self.wrapped_notes = ko.computed({
read: function() {
return this.public_notes();
},
write: function(value) {
value = wordWrapText(value, 300);
self.public_notes(value);
},
owner: this
});
self.wrapped_footer = ko.computed({
read: function() {
return this.invoice_footer();
},
write: function(value) {
value = wordWrapText(value, 600);
self.invoice_footer(value);
},
owner: this
});
self.removeItem = function(item) { self.removeItem = function(item) {
self.invoice_items.remove(item); self.invoice_items.remove(item);
refreshPDF(true); refreshPDF(true);
@ -745,18 +711,6 @@ function ItemModel(data) {
ko.mapping.fromJS(data, {}, this); ko.mapping.fromJS(data, {}, this);
} }
self.wrapped_notes = ko.computed({
read: function() {
return this.notes();
},
write: function(value) {
//value = wordWrapText(value, 235);
self.notes(value);
//onItemChange();
},
owner: this
});
this.totals = ko.observable(); this.totals = ko.observable();
this.totals.rawTotal = ko.computed(function() { this.totals.rawTotal = ko.computed(function() {