diff --git a/Views/Home/_GarageDisplay.cshtml b/Views/Home/_GarageDisplay.cshtml index 21cca0d..2f64e9e 100644 --- a/Views/Home/_GarageDisplay.cshtml +++ b/Views/Home/_GarageDisplay.cshtml @@ -10,6 +10,12 @@ { @recordTag } + + @foreach (string recordTag in recordTags) + { + + } + } diff --git a/Views/Vehicle/_CollisionRecords.cshtml b/Views/Vehicle/_CollisionRecords.cshtml index 92adb07..8c2187b 100644 --- a/Views/Vehicle/_CollisionRecords.cshtml +++ b/Views/Vehicle/_CollisionRecords.cshtml @@ -15,6 +15,12 @@ { @recordTag } + + @foreach (string recordTag in recordTags) + { + + } +
@if (enableCsvImports) diff --git a/Views/Vehicle/_ServiceRecords.cshtml b/Views/Vehicle/_ServiceRecords.cshtml index 73feff4..56e2043 100644 --- a/Views/Vehicle/_ServiceRecords.cshtml +++ b/Views/Vehicle/_ServiceRecords.cshtml @@ -15,6 +15,12 @@ { @recordTag } + + @foreach (string recordTag in recordTags) + { + + } +
@if (enableCsvImports) diff --git a/Views/Vehicle/_UpgradeRecords.cshtml b/Views/Vehicle/_UpgradeRecords.cshtml index 5f4aead..52db9de 100644 --- a/Views/Vehicle/_UpgradeRecords.cshtml +++ b/Views/Vehicle/_UpgradeRecords.cshtml @@ -15,6 +15,12 @@ { @recordTag } + + @foreach (string recordTag in recordTags) + { + + } +
@if (enableCsvImports) diff --git a/wwwroot/js/shared.js b/wwwroot/js/shared.js index f0da3c2..43b4f8d 100644 --- a/wwwroot/js/shared.js +++ b/wwwroot/js/shared.js @@ -139,8 +139,14 @@ function initDatePicker(input, futureOnly) { }); } } -function initTagSelector(input) { - input.tagsinput(); +function initTagSelector(input, noDataList) { + if (noDataList) { + input.tagsinput({ + useDataList: false + }); + } else { + input.tagsinput(); + } } function showMobileNav() { diff --git a/wwwroot/js/vehicle.js b/wwwroot/js/vehicle.js index db47f25..6322725 100644 --- a/wwwroot/js/vehicle.js +++ b/wwwroot/js/vehicle.js @@ -214,7 +214,7 @@ function editVehicle(vehicleId) { $.get(`/Vehicle/GetEditVehiclePartialViewById?vehicleId=${vehicleId}`, function (data) { if (data) { $("#editVehicleModalContent").html(data); - initTagSelector($("#inputTag")); + initTagSelector($("#inputTag"), true); $('#editVehicleModal').modal('show'); } }); diff --git a/wwwroot/lib/bootstrap-tagsinput/bootstrap-tagsinput.js b/wwwroot/lib/bootstrap-tagsinput/bootstrap-tagsinput.js index 9bb0e20..e281de6 100644 --- a/wwwroot/lib/bootstrap-tagsinput/bootstrap-tagsinput.js +++ b/wwwroot/lib/bootstrap-tagsinput/bootstrap-tagsinput.js @@ -34,18 +34,22 @@ */ function TagsInput(element, options) { this.itemsArray = []; - this.$element = $(element); this.$element.hide(); - + this.isSelect = (element.tagName === 'SELECT'); this.multiple = (this.isSelect && element.hasAttribute('multiple')); this.objectItems = options && options.itemValue; this.placeholderText = element.hasAttribute('placeholder') ? this.$element.attr('placeholder') : ''; this.inputSize = Math.max(1, this.placeholderText.length); + var useDataList = true; + if (options != undefined && !options.useDataList) { + useDataList = false; + } + this.$container = $('
'); - this.$input = $('').appendTo(this.$container); + this.$input = $(`').appendTo(this.$container); this.$element.before(this.$container); @@ -422,6 +426,32 @@ $input.attr('size', Math.max(this.inputSize, $input.val().length)); }, self)); + self.$container.on('input', 'input', $.proxy(function (event) { + if (event.originalEvent.data == undefined) { + var $input = $(event.target); + var text = $input.val(), + maxLengthReached = self.options.maxChars && text.length >= self.options.maxChars; + if (self.options.freeInput && (keyCombinationInList(event, self.options.confirmKeys) || maxLengthReached)) { + //check if confirm keys are in input and then replace them. + text = text.replace(String.fromCharCode(event.which), "") + // Only attempt to add a tag if there is data in the field + if (text.length !== 0) { + self.add(maxLengthReached ? text.substr(0, self.options.maxChars) : text); + $input.val(''); + } + + // If the field is empty, let the event triggered fire as usual + if (self.options.cancelConfirmKeysOnEmpty === false) { + event.preventDefault(); + } + } + var textLength = $input.val().length, + wordSpace = Math.ceil(textLength / 5), + size = textLength + wordSpace + 1; + $input.attr('size', Math.max(this.inputSize, $input.val().length)); + }; + })); + self.$container.on('keypress', 'input', $.proxy(function(event) { var $input = $(event.target);