BigW Consortium Gitlab

Commit 5b2ce9ad by Jacob Schatz

Merge branch 'label-dropdown-errors' into 'master'

Shows error messages when trying to create label in dropdown menu Closes #14495 ![Screen_Shot_2016-03-22_at_14.46.10](/uploads/cdcaa51f4d41237f8027efbd0f894bcd/Screen_Shot_2016-03-22_at_14.46.10.png) See merge request !3345
parents 4896d49a 07da8651
...@@ -74,6 +74,8 @@ ...@@ -74,6 +74,8 @@
dataType: "json" dataType: "json"
).done (label) -> ).done (label) ->
callback(label) callback(label)
.error (message) ->
callback(message.responseJSON)
# Return group projects list. Filtered by query # Return group projects list. Filtered by query
groupProjects: (group_id, query, callback) -> groupProjects: (group_id, query, callback) ->
......
...@@ -14,6 +14,9 @@ class @LabelsSelect ...@@ -14,6 +14,9 @@ class @LabelsSelect
defaultLabel = $dropdown.data('default-label') defaultLabel = $dropdown.data('default-label')
if newLabelField.length if newLabelField.length
$newLabelError = $dropdown.parent().find('.js-label-error')
$newLabelError.hide()
$('.suggest-colors-dropdown a').on 'click', (e) -> $('.suggest-colors-dropdown a').on 'click', (e) ->
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
...@@ -27,6 +30,7 @@ class @LabelsSelect ...@@ -27,6 +30,7 @@ class @LabelsSelect
e.stopPropagation() e.stopPropagation()
if newLabelField.val() isnt '' and newColorField.val() isnt '' if newLabelField.val() isnt '' and newColorField.val() isnt ''
$newLabelError.hide()
$('.js-new-label-btn').disable() $('.js-new-label-btn').disable()
# Create new label with API # Create new label with API
...@@ -35,6 +39,12 @@ class @LabelsSelect ...@@ -35,6 +39,12 @@ class @LabelsSelect
color: newColorField.val() color: newColorField.val()
}, (label) -> }, (label) ->
$('.js-new-label-btn').enable() $('.js-new-label-btn').enable()
if label.message?
$newLabelError
.text label.message
.show()
else
$('.dropdown-menu-back', $dropdown.parent()).trigger 'click' $('.dropdown-menu-back', $dropdown.parent()).trigger 'click'
$dropdown.glDropdown( $dropdown.glDropdown(
......
...@@ -45,3 +45,10 @@ ...@@ -45,3 +45,10 @@
.label-subscription { .label-subscription {
display: inline-block; display: inline-block;
} }
.dropdown-labels-error {
padding: 5px 10px;
margin-bottom: 10px;
background-color: $gl-danger;
color: $white-light;
}
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
.dropdown-page-two .dropdown-page-two
= dropdown_title("Create new label", back: true) = dropdown_title("Create new label", back: true)
= dropdown_content do = dropdown_content do
.dropdown-labels-error.js-label-error
%input#new_label_color{type: "hidden"} %input#new_label_color{type: "hidden"}
%input#new_label_name.dropdown-input-field{type: "text", placeholder: "Name new label"} %input#new_label_name.dropdown-input-field{type: "text", placeholder: "Name new label"}
.dropdown-label-color-preview.js-dropdown-label-color-preview .dropdown-label-color-preview.js-dropdown-label-color-preview
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment