Implemented issue creation on issues list.
parent
ff41e86f2b
commit
3fb545edf2
|
@ -22,22 +22,65 @@
|
||||||
taiga = @.taiga
|
taiga = @.taiga
|
||||||
bindOnce = @.taiga.bindOnce
|
bindOnce = @.taiga.bindOnce
|
||||||
|
|
||||||
|
module = angular.module("taigaIssues")
|
||||||
|
|
||||||
|
#############################################################################
|
||||||
|
## Issue Create Lightbox Directive
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
CreateIssueDirective = ($repo, $model, $rs, $rootscope) ->
|
CreateIssueDirective = ($repo, $model, $rs, $rootscope) ->
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
|
form = $el.find("form").checksley()
|
||||||
|
$scope.issue = {}
|
||||||
|
|
||||||
$scope.$on "issueform:new", ->
|
$scope.$on "issueform:new", ->
|
||||||
$el.removeClass("hidden")
|
$el.removeClass("hidden")
|
||||||
|
|
||||||
|
$scope.issue = {
|
||||||
|
project: $scope.projectId
|
||||||
|
subject: ""
|
||||||
|
status: $scope.project.default_issue_status
|
||||||
|
type: $scope.project.default_issue_type
|
||||||
|
priority: $scope.project.default_priority
|
||||||
|
severity: $scope.project.default_severity
|
||||||
|
estimated_start: null
|
||||||
|
estimated_finish: null
|
||||||
|
}
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
$el.off()
|
$el.off()
|
||||||
|
|
||||||
|
submit = ->
|
||||||
|
console.log $scope.issue
|
||||||
|
if not form.validate()
|
||||||
|
return
|
||||||
|
|
||||||
|
promise = $repo.create("issues", $scope.issue)
|
||||||
|
|
||||||
|
promise.then (data) ->
|
||||||
|
$el.addClass("hidden")
|
||||||
|
console.log "succcess", data
|
||||||
|
$rootscope.$broadcast("issueform:new:success", data)
|
||||||
|
|
||||||
|
# FIXME: error handling?
|
||||||
|
promise.then null, ->
|
||||||
|
console.log "FAIL"
|
||||||
|
|
||||||
$el.on "click", ".close", (event) ->
|
$el.on "click", ".close", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
$el.addClass("hidden")
|
$el.addClass("hidden")
|
||||||
|
|
||||||
|
$el.on "click", ".button-green", (event) ->
|
||||||
|
event.preventDefault()
|
||||||
|
submit()
|
||||||
|
|
||||||
|
$el.on "submit", "form", (event) ->
|
||||||
|
event.preventDefault()
|
||||||
|
submit()
|
||||||
|
|
||||||
return {link:link}
|
return {link:link}
|
||||||
|
|
||||||
|
|
||||||
module = angular.module("taigaIssues")
|
|
||||||
module.directive("tgLbCreateIssue", [
|
module.directive("tgLbCreateIssue", [
|
||||||
"$tgRepo",
|
"$tgRepo",
|
||||||
"$tgModel",
|
"$tgModel",
|
||||||
|
@ -46,7 +89,39 @@ module.directive("tgLbCreateIssue", [
|
||||||
CreateIssueDirective
|
CreateIssueDirective
|
||||||
])
|
])
|
||||||
|
|
||||||
AddWatcherDirective = () ->
|
#############################################################################
|
||||||
|
## Issue Create Lightbox Directive
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
|
# BulkCreateIssuesDirective = ($repo, $model, $rs, $rootscope) ->
|
||||||
|
# link = ($scope, $el, $attrs) ->
|
||||||
|
# $scope.$on "issueform:new", ->
|
||||||
|
# $el.removeClass("hidden")
|
||||||
|
#
|
||||||
|
# $scope.$on "$destroy", ->
|
||||||
|
# $el.off()
|
||||||
|
#
|
||||||
|
# $el.on "click", ".close", (event) ->
|
||||||
|
# event.preventDefault()
|
||||||
|
# $el.addClass("hidden")
|
||||||
|
#
|
||||||
|
# return {link:link}
|
||||||
|
|
||||||
|
# module.directive("tgLbCreateIssue", [
|
||||||
|
# "$tgRepo",
|
||||||
|
# "$tgModel",
|
||||||
|
# "$tgResources",
|
||||||
|
# "$rootScope",
|
||||||
|
# CreateIssueDirective
|
||||||
|
# ])
|
||||||
|
|
||||||
|
#############################################################################
|
||||||
|
## Watchers Lightbox directive
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
|
# FIXME: rename to: WatchersLightboxDirective/tgLbWatchers
|
||||||
|
|
||||||
|
AddWatcherDirective = ->
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
$scope.usersSearch = {}
|
$scope.usersSearch = {}
|
||||||
$scope.$on "watcher:add", ->
|
$scope.$on "watcher:add", ->
|
||||||
|
@ -72,21 +147,27 @@ AddWatcherDirective = () ->
|
||||||
|
|
||||||
module.directive("tgLbAddWatcher", AddWatcherDirective)
|
module.directive("tgLbAddWatcher", AddWatcherDirective)
|
||||||
|
|
||||||
|
#############################################################################
|
||||||
|
## AssignedTo Lightbox Directive
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
EditAssignedToDirective = () ->
|
# FIXME: rename to: AssignedToLightboxDirective/tgLbAssignedto
|
||||||
|
|
||||||
|
EditAssignedToDirective = ->
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
editingElement = null
|
editingElement = null
|
||||||
|
|
||||||
updateScopeFilteringUsers = (searchingText) ->
|
updateScopeFilteringUsers = (searchingText) ->
|
||||||
usersById = _.clone($scope.usersById, false)
|
usersById = _.clone($scope.usersById, false)
|
||||||
#Exclude selected user
|
# Exclude selected user
|
||||||
if $scope.selectedUser?
|
if $scope.selectedUser?
|
||||||
delete usersById[$scope.selectedUser.id]
|
delete usersById[$scope.selectedUser.id]
|
||||||
|
|
||||||
#Filter text
|
# Filter text
|
||||||
usersById = _.filter(usersById, (user) -> _.contains(user.full_name_display, searchingText))
|
usersById = _.filter usersById, (user) ->
|
||||||
|
return _.contains(user.full_name_display, searchingText)
|
||||||
|
|
||||||
#Return max of 5 elements
|
# Return max of 5 elements
|
||||||
users = _.map(usersById, (user) -> user)
|
users = _.map(usersById, (user) -> user)
|
||||||
$scope.AssignedToUsersSearch = searchingText
|
$scope.AssignedToUsersSearch = searchingText
|
||||||
$scope.filteringUsers = users.length > 5
|
$scope.filteringUsers = users.length > 5
|
||||||
|
@ -95,9 +176,11 @@ EditAssignedToDirective = () ->
|
||||||
$scope.$on "assigned-to:add", (ctx, element) ->
|
$scope.$on "assigned-to:add", (ctx, element) ->
|
||||||
editingElement = element
|
editingElement = element
|
||||||
assignedToId = editingElement?.assigned_to
|
assignedToId = editingElement?.assigned_to
|
||||||
|
|
||||||
$scope.selectedUser = null
|
$scope.selectedUser = null
|
||||||
$scope.selectedUser = $scope.usersById[assignedToId] if assignedToId?
|
$scope.selectedUser = $scope.usersById[assignedToId] if assignedToId?
|
||||||
updateScopeFilteringUsers("")
|
updateScopeFilteringUsers("")
|
||||||
|
|
||||||
$el.removeClass("hidden")
|
$el.removeClass("hidden")
|
||||||
$el.find("input").focus()
|
$el.find("input").focus()
|
||||||
|
|
||||||
|
@ -117,6 +200,7 @@ EditAssignedToDirective = () ->
|
||||||
$el.on "click", ".remove-assigned-to", (event) ->
|
$el.on "click", ".remove-assigned-to", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
|
|
||||||
if editingElement?
|
if editingElement?
|
||||||
editingElement.assigned_to = null
|
editingElement.assigned_to = null
|
||||||
|
|
||||||
|
|
|
@ -56,12 +56,23 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
|
||||||
promise.then null, ->
|
promise.then null, ->
|
||||||
console.log "FAIL" #TODO
|
console.log "FAIL" #TODO
|
||||||
|
|
||||||
|
@scope.$on "issueform:new:succcess", =>
|
||||||
|
@.loadIssues()
|
||||||
|
@.loadFilters()
|
||||||
|
|
||||||
loadProject: ->
|
loadProject: ->
|
||||||
return @rs.projects.get(@scope.projectId).then (project) =>
|
return @rs.projects.get(@scope.projectId).then (project) =>
|
||||||
@scope.project = project
|
@scope.project = project
|
||||||
|
|
||||||
|
# TODO: add issueTypeList and issueTypeById
|
||||||
@scope.issueStatusById = groupBy(project.issue_statuses, (x) -> x.id)
|
@scope.issueStatusById = groupBy(project.issue_statuses, (x) -> x.id)
|
||||||
|
@scope.issueStatusList = _.sortBy(project.issue_statuses, "order")
|
||||||
@scope.severityById = groupBy(project.severities, (x) -> x.id)
|
@scope.severityById = groupBy(project.severities, (x) -> x.id)
|
||||||
|
@scope.severityList = _.sortBy(project.severities, "order")
|
||||||
@scope.priorityById = groupBy(project.priorities, (x) -> x.id)
|
@scope.priorityById = groupBy(project.priorities, (x) -> x.id)
|
||||||
|
@scope.priorityList = _.sortBy(project.priorities, "order")
|
||||||
|
|
||||||
|
console.log @scope.priorityList
|
||||||
@scope.membersById = groupBy(project.memberships, (x) -> x.user)
|
@scope.membersById = groupBy(project.memberships, (x) -> x.user)
|
||||||
return project
|
return project
|
||||||
|
|
||||||
|
@ -154,7 +165,6 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
|
||||||
|
|
||||||
loadIssues: ->
|
loadIssues: ->
|
||||||
filters = @.prepareFilters()
|
filters = @.prepareFilters()
|
||||||
console.log filters
|
|
||||||
|
|
||||||
promise = @rs.issues.list(@scope.projectId, filters).then (data) =>
|
promise = @rs.issues.list(@scope.projectId, filters).then (data) =>
|
||||||
@scope.issues = data.models
|
@scope.issues = data.models
|
||||||
|
@ -175,6 +185,15 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
|
||||||
.then(=> @.loadFilters())
|
.then(=> @.loadFilters())
|
||||||
.then(=> @.loadIssues())
|
.then(=> @.loadIssues())
|
||||||
|
|
||||||
|
# Functions used from templates
|
||||||
|
addNewIssue: ->
|
||||||
|
console.log "Kakita"
|
||||||
|
@rootscope.$broadcast("issueform:new")
|
||||||
|
|
||||||
|
addIssuesInBulk: ->
|
||||||
|
@rootscope.$broadcast("issueform:bulk")
|
||||||
|
|
||||||
|
|
||||||
module.controller("IssuesController", IssuesController)
|
module.controller("IssuesController", IssuesController)
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
|
@ -18,8 +18,8 @@ block content
|
||||||
// Paginator is rended using js.
|
// Paginator is rended using js.
|
||||||
div.paginator.issues-paginator
|
div.paginator.issues-paginator
|
||||||
|
|
||||||
div.hidden.lightbox.lightbox_add-issue
|
div.hidden.lightbox.lightbox_add-issue(tg-lb-create-issue)
|
||||||
include views/modules/lightbox_add-issue
|
include views/modules/lightbox_add-issue
|
||||||
|
|
||||||
div.hidden.lightbox.lightbox_add-bulk
|
div.hidden.lightbox.lightbox_add-bulk(tg-lb-create-bulk-issues)
|
||||||
include views/modules/lightbox_add-bulk
|
include views/modules/lightbox_add-bulk
|
||||||
|
|
|
@ -3,32 +3,24 @@ a.close(href="", title="close")
|
||||||
form
|
form
|
||||||
h2.title Add Issue
|
h2.title Add Issue
|
||||||
fieldset
|
fieldset
|
||||||
input(type="text", placeholder="Issue description")
|
input(type="text", ng-model="issue.subject", placeholder="Issue description",
|
||||||
|
data-required="true", data-maxlength="500")
|
||||||
div.fieldset-row
|
div.fieldset-row
|
||||||
|
// fieldset
|
||||||
|
// select.type
|
||||||
|
// option(value="Type") Type
|
||||||
fieldset
|
fieldset
|
||||||
select.type
|
select.priority(ng-model="issue.priority", ng-options="p.id as p.name for p in priorityList")
|
||||||
option(value="Type") Type
|
|
||||||
fieldset
|
fieldset
|
||||||
select.priority
|
select.severity(ng-model="issue.severity", ng-options="s.id as s.name for s in severityList")
|
||||||
option(value="priority") Priority
|
|
||||||
fieldset
|
fieldset
|
||||||
select.severity
|
input(type="text", placeholder="Tags", tg-tags, ng-model="issue.tags")
|
||||||
option(value="severity") Severity
|
|
||||||
//-
|
|
||||||
div.fieldset-row
|
|
||||||
fieldset
|
fieldset
|
||||||
select.assigned-to
|
textarea.description(placeholder="description", ng-model="issue.description")
|
||||||
option(value="assigned-to") Assigned to
|
|
||||||
fieldset
|
// include lightbox-attachments
|
||||||
select.status
|
input(type="submit", style="display:none")
|
||||||
option(value="status") Status
|
|
||||||
fieldset
|
|
||||||
input(type="checkbox", id="is-blocked")
|
|
||||||
label(for="is-blocked") is blocked?
|
|
||||||
fieldset
|
|
||||||
input(type="text", placeholder="Add tags")
|
|
||||||
fieldset
|
|
||||||
textarea.description(placeholder="description")
|
|
||||||
include lightbox-attachments
|
|
||||||
a.button.button-green(href="", title="Save")
|
a.button.button-green(href="", title="Save")
|
||||||
span Create
|
span Create
|
||||||
|
|
|
@ -11,8 +11,8 @@ section.list-filters
|
||||||
// | SHOW GRAPH
|
// | SHOW GRAPH
|
||||||
|
|
||||||
div.new-issue
|
div.new-issue
|
||||||
a.button.button-green(href="")
|
a.button.button-green(href="", ng-click="ctrl.addNewIssue()")
|
||||||
span.text
|
span.text
|
||||||
| + NEW ISSUE
|
| + NEW ISSUE
|
||||||
a.button-bulk(href="")
|
a.button-bulk(href="", ng-click="ctrl.addIssuesInBulk()")
|
||||||
span.icon.icon-bulk
|
span.icon.icon-bulk
|
Loading…
Reference in New Issue