Improve add-epic form
parent
7070f181ac
commit
7aa281c520
|
@ -28,14 +28,16 @@ class ColorSelectorController
|
||||||
if @.initColor
|
if @.initColor
|
||||||
@.color = @.initColor
|
@.color = @.initColor
|
||||||
|
|
||||||
@.displaycolorList = false
|
@.displayColorList = false
|
||||||
|
|
||||||
toggleColorList: () ->
|
|
||||||
@.displaycolorList = !@.displaycolorList
|
|
||||||
|
|
||||||
|
resetColor: () ->
|
||||||
if @.isRequired and not @.color
|
if @.isRequired and not @.color
|
||||||
@.color = @.initColor
|
@.color = @.initColor
|
||||||
|
|
||||||
|
toggleColorList: () ->
|
||||||
|
@.displayColorList = !@.displayColorList
|
||||||
|
@.resetColor()
|
||||||
|
|
||||||
onSelectDropdownColor: (color) ->
|
onSelectDropdownColor: (color) ->
|
||||||
@.color = color
|
@.color = color
|
||||||
@.onSelectColor({color: color})
|
@.onSelectColor({color: color})
|
||||||
|
|
|
@ -30,7 +30,8 @@ ColorSelectorDirective = ($timeout) ->
|
||||||
return if _timeout
|
return if _timeout
|
||||||
|
|
||||||
_timeout = $timeout (() ->
|
_timeout = $timeout (() ->
|
||||||
scope.vm.toggleColorList()
|
ctrl.displayColorList = false
|
||||||
|
ctrl.resetColor()
|
||||||
), 400
|
), 400
|
||||||
|
|
||||||
el.find('.color-selector')
|
el.find('.color-selector')
|
||||||
|
@ -43,15 +44,15 @@ ColorSelectorDirective = ($timeout) ->
|
||||||
|
|
||||||
return {
|
return {
|
||||||
link: link,
|
link: link,
|
||||||
scope:{
|
|
||||||
isRequired: "="
|
|
||||||
onSelectColor: "&",
|
|
||||||
initColor: "="
|
|
||||||
},
|
|
||||||
templateUrl:"components/color-selector/color-selector.html",
|
templateUrl:"components/color-selector/color-selector.html",
|
||||||
controller: "ColorSelectorCtrl",
|
controller: "ColorSelectorCtrl",
|
||||||
controllerAs: "vm",
|
controllerAs: "vm",
|
||||||
bindToController: true
|
bindToController: {
|
||||||
|
isRequired: "=",
|
||||||
|
onSelectColor: "&",
|
||||||
|
initColor: "="
|
||||||
|
},
|
||||||
|
scope: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
ng-class="{'empty-color': !vm.color}"
|
ng-class="{'empty-color': !vm.color}"
|
||||||
ng-style="{'background': vm.color}"
|
ng-style="{'background': vm.color}"
|
||||||
)
|
)
|
||||||
.color-selector-dropdown(ng-if="vm.displaycolorList")
|
.color-selector-dropdown(ng-if="vm.displayColorList")
|
||||||
ul.color-selector-dropdown-list.e2e-color-dropdown
|
ul.color-selector-dropdown-list.e2e-color-dropdown
|
||||||
li.color-selector-option(
|
li.color-selector-option(
|
||||||
ng-repeat="color in vm.colorList"
|
ng-repeat="color in vm.colorList"
|
||||||
|
|
|
@ -21,16 +21,16 @@ taiga = @.taiga
|
||||||
trim = taiga.trim
|
trim = taiga.trim
|
||||||
getRandomDefaultColor = taiga.getRandomDefaultColor
|
getRandomDefaultColor = taiga.getRandomDefaultColor
|
||||||
|
|
||||||
module = angular.module("taigaEpics")
|
|
||||||
|
|
||||||
class CreateEpicController
|
class CreateEpicController
|
||||||
@.$inject = [
|
@.$inject = [
|
||||||
"tgResources"
|
"tgResources"
|
||||||
|
"$tgConfirm"
|
||||||
"tgAttachmentsService"
|
"tgAttachmentsService"
|
||||||
"$q"
|
"$q"
|
||||||
]
|
]
|
||||||
|
|
||||||
constructor: (@rs, @attachmentsService, @q) ->
|
constructor: (@rs, @confirm, @attachmentsService, @q) ->
|
||||||
@.newEpic = {
|
@.newEpic = {
|
||||||
color: getRandomDefaultColor()
|
color: getRandomDefaultColor()
|
||||||
project: @.project.id
|
project: @.project.id
|
||||||
|
@ -40,13 +40,22 @@ class CreateEpicController
|
||||||
@.attachments = Immutable.List()
|
@.attachments = Immutable.List()
|
||||||
|
|
||||||
createEpic: () ->
|
createEpic: () ->
|
||||||
promise = @rs.epics.post(@.newEpic)
|
return if not @.validateForm()
|
||||||
|
|
||||||
|
@.loading = true
|
||||||
|
|
||||||
|
promise = @rs.epics.post(@.newEpic)
|
||||||
promise.then (response) =>
|
promise.then (response) =>
|
||||||
@._createAttachments(response.data)
|
@._createAttachments(response.data)
|
||||||
|
promise.then (response) =>
|
||||||
promise.then (data) =>
|
|
||||||
@.onCreateEpic()
|
@.onCreateEpic()
|
||||||
|
promise.then null, (response) =>
|
||||||
|
@.setFormErrors(response.data)
|
||||||
|
|
||||||
|
if response.data._error_message
|
||||||
|
confirm.notify("error", response.data._error_message)
|
||||||
|
promise.finally () =>
|
||||||
|
@.loading = false
|
||||||
|
|
||||||
# Color selector
|
# Color selector
|
||||||
selectColor: (color) ->
|
selectColor: (color) ->
|
||||||
|
@ -71,4 +80,4 @@ class CreateEpicController
|
||||||
return attachmentsService.upload(attachment.file, epic.id, epic.project, 'epic')
|
return attachmentsService.upload(attachment.file, epic.id, epic.project, 'epic')
|
||||||
return @q.all(promises)
|
return @q.all(promises)
|
||||||
|
|
||||||
module.controller("CreateEpicCtrl", CreateEpicController)
|
angular.module("taigaEpics").controller("CreateEpicCtrl", CreateEpicController)
|
||||||
|
|
|
@ -20,16 +20,25 @@
|
||||||
module = angular.module('taigaEpics')
|
module = angular.module('taigaEpics')
|
||||||
|
|
||||||
CreateEpicDirective = () ->
|
CreateEpicDirective = () ->
|
||||||
|
link = (scope, el, attrs, ctrl) ->
|
||||||
|
form = el.find("form").checksley()
|
||||||
|
|
||||||
|
ctrl.validateForm = =>
|
||||||
|
return form.validate()
|
||||||
|
|
||||||
|
ctrl.setFormErrors = (errors) =>
|
||||||
|
form.setErrors(errors)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
link: link,
|
||||||
templateUrl:"epics/create-epic/create-epic.html",
|
templateUrl:"epics/create-epic/create-epic.html",
|
||||||
controller: "CreateEpicCtrl",
|
controller: "CreateEpicCtrl",
|
||||||
controllerAs: "vm",
|
controllerAs: "vm",
|
||||||
bindToController: true,
|
bindToController: {
|
||||||
scope: {
|
|
||||||
project: '=',
|
project: '=',
|
||||||
onCreateEpic: '&'
|
onCreateEpic: '&'
|
||||||
}
|
},
|
||||||
|
scope: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateEpicDirective.$inject = []
|
CreateEpicDirective.$inject = []
|
||||||
|
|
|
@ -14,23 +14,19 @@ tg-lightbox-close
|
||||||
input.e2e-create-epic-subject(
|
input.e2e-create-epic-subject(
|
||||||
type="text"
|
type="text"
|
||||||
name="subject"
|
name="subject"
|
||||||
maxlength="140"
|
|
||||||
ng-model="vm.newEpic.subject"
|
ng-model="vm.newEpic.subject"
|
||||||
tg-auto-select
|
tg-auto-select
|
||||||
placeholder="{{'COMMON.FIELDS.SUBJECT' | translate}}"
|
placeholder="{{'COMMON.FIELDS.SUBJECT' | translate}}"
|
||||||
required
|
data-required="true"
|
||||||
|
data-maxlength="140"
|
||||||
)
|
)
|
||||||
fieldset
|
fieldset
|
||||||
select.e2e-create-epic-status(
|
select.e2e-create-epic-status(
|
||||||
id="epic-status"
|
id="epic-status"
|
||||||
name="status"
|
name="status"
|
||||||
ng-model="vm.newEpic.status"
|
ng-model="vm.newEpic.status"
|
||||||
|
ng-options="s.id as s.name for s in vm.project.epic_statuses | orderBy:'order'"
|
||||||
)
|
)
|
||||||
option(
|
|
||||||
ng-repeat="status in vm.project.epic_statuses | orderBy:'order'"
|
|
||||||
ng-value="::status.id"
|
|
||||||
ng-selected="vm.project.default_epic_status"
|
|
||||||
) {{::status.name}}
|
|
||||||
fieldset.tags-block
|
fieldset.tags-block
|
||||||
tg-tag-line-common(
|
tg-tag-line-common(
|
||||||
project="vm.project"
|
project="vm.project"
|
||||||
|
@ -93,7 +89,9 @@ tg-lightbox-close
|
||||||
placeholder="{{'EPICS.CREATE.BLOCKED_NOTE_PLACEHOLDER' | translate}}"
|
placeholder="{{'EPICS.CREATE.BLOCKED_NOTE_PLACEHOLDER' | translate}}"
|
||||||
)
|
)
|
||||||
fieldset
|
fieldset
|
||||||
input.button-green.create-epic-button.e2e-create-epic-button(
|
button.button-green.create-epic-button.e2e-create-epic-button(
|
||||||
type="submit"
|
type="submit"
|
||||||
|
tg-loading="vm.loading"
|
||||||
|
title="{{ 'EPICS.CREATE.CREATE_EPIC' | translate }}"
|
||||||
translate="EPICS.CREATE.CREATE_EPIC"
|
translate="EPICS.CREATE.CREATE_EPIC"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue