Finishing US CRUD in backlog
parent
e592ceab25
commit
79cdc0c7e4
|
@ -19,28 +19,74 @@
|
||||||
# File: modules/backlog/lightboxes.coffee
|
# File: modules/backlog/lightboxes.coffee
|
||||||
###
|
###
|
||||||
|
|
||||||
CreateEditUserstoryDirective = ($repo, $model) ->
|
CreateEditUserstoryDirective = ($repo, $model, $rs) ->
|
||||||
|
|
||||||
|
editDescription = ($scope, $el) ->
|
||||||
|
$el.find('.markdown-preview a').removeClass("active")
|
||||||
|
$el.find('.markdown-preview a.edit').addClass("active")
|
||||||
|
descriptionDOM = $el.find("textarea.description")
|
||||||
|
descriptionPreviewDOM = $el.find(".description-preview")
|
||||||
|
descriptionDOM.show()
|
||||||
|
descriptionPreviewDOM.hide()
|
||||||
|
|
||||||
|
previewDescription = ($scope, $el) ->
|
||||||
|
$el.find('.markdown-preview a').removeClass("active")
|
||||||
|
$el.find('.markdown-preview a.preview').addClass("active")
|
||||||
|
descriptionDOM = $el.find("textarea.description")
|
||||||
|
descriptionPreviewDOM = $el.find(".description-preview")
|
||||||
|
$rs.mdrender.render($scope.projectId, $scope.us.description).then (data) ->
|
||||||
|
descriptionDOM.hide()
|
||||||
|
descriptionPreviewDOM.html(data.data)
|
||||||
|
descriptionPreviewDOM.show()
|
||||||
|
|
||||||
link = ($scope, $el, attrs) ->
|
link = ($scope, $el, attrs) ->
|
||||||
$scope.us = {}
|
$ctrl = $el.closest("div.wrapper").controller()
|
||||||
# TODO: defaults
|
isNew = true
|
||||||
|
|
||||||
$scope.$on "usform:new", ->
|
$scope.$on "usform:new", ->
|
||||||
$scope.us = {}
|
$scope.us = {
|
||||||
|
project: $scope.projectId
|
||||||
|
is_archived: false
|
||||||
|
order: 0
|
||||||
|
status: $scope.project.default_us_status
|
||||||
|
}
|
||||||
|
isNew = true
|
||||||
|
editDescription($scope, $el)
|
||||||
|
# Update texts for creation
|
||||||
|
$el.find(".button-green span").html("Create")
|
||||||
|
$el.find(".title").html("New user story ")
|
||||||
$el.removeClass("hidden")
|
$el.removeClass("hidden")
|
||||||
|
|
||||||
$scope.$on "usform:edit", (ctx, us) ->
|
$scope.$on "usform:edit", (ctx, us) ->
|
||||||
$el.removeClass("hidden")
|
|
||||||
$scope.us = us
|
$scope.us = us
|
||||||
|
isNew = false
|
||||||
|
editDescription($scope, $el)
|
||||||
|
# Update texts for edition
|
||||||
|
$el.find(".button-green span").html("Save")
|
||||||
|
$el.find(".title").html("Edit user story ")
|
||||||
|
$el.removeClass("hidden")
|
||||||
|
|
||||||
|
# Update requirement info (team, client or blocked)
|
||||||
|
if us.is_blocked
|
||||||
|
$el.find(".blocked-note").show()
|
||||||
|
$el.find("label.blocked").addClass("selected")
|
||||||
|
if us.team_requirement
|
||||||
|
$el.find("label.team-requirement").addClass("selected")
|
||||||
|
if us.is_blocked
|
||||||
|
$el.find("label.client-requirement").addClass("selected")
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
$el.off()
|
$el.off()
|
||||||
|
|
||||||
# Dom Event Handlers
|
# Dom Event Handlers
|
||||||
$el.on "click", ".markdown-preview a", (event) ->
|
|
||||||
event.preventDefault()
|
|
||||||
target = angular.element(event.currentTarget)
|
|
||||||
|
|
||||||
target.parent().find("a").removeClass("active")
|
$el.on "click", ".markdown-preview a.edit", (event) ->
|
||||||
target.addClass("active")
|
event.preventDefault()
|
||||||
|
editDescription($scope, $el)
|
||||||
|
|
||||||
|
$el.on "click", ".markdown-preview a.preview", (event) ->
|
||||||
|
event.preventDefault()
|
||||||
|
previewDescription($scope, $el)
|
||||||
|
|
||||||
$el.on "click", ".close", (event) ->
|
$el.on "click", ".close", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
@ -48,7 +94,31 @@ CreateEditUserstoryDirective = ($repo, $model) ->
|
||||||
|
|
||||||
$el.on "click", ".button-green", (event) ->
|
$el.on "click", ".button-green", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
console.log $scope.us
|
if isNew
|
||||||
|
promise = $repo.create("userstories", $scope.us)
|
||||||
|
else
|
||||||
|
promise = $repo.save($scope.us)
|
||||||
|
|
||||||
|
promise.then (data) ->
|
||||||
|
$el.addClass("hidden")
|
||||||
|
$ctrl.loadUserstories()
|
||||||
|
|
||||||
|
$el.on "click", "label.blocked", (event) ->
|
||||||
|
event.preventDefault()
|
||||||
|
target = angular.element(event.currentTarget)
|
||||||
|
target.toggleClass("selected")
|
||||||
|
$scope.us.is_blocked = not $scope.us.is_blocked
|
||||||
|
$el.find(".blocked-note").toggle(400)
|
||||||
|
|
||||||
|
$el.on "click", "label.team-requirement", (event) ->
|
||||||
|
event.preventDefault()
|
||||||
|
angular.element(event.currentTarget).toggleClass("selected")
|
||||||
|
$scope.us.team_requirement = not $scope.us.team_requirement
|
||||||
|
|
||||||
|
$el.on "click", "label.client-requirement", (event) ->
|
||||||
|
event.preventDefault()
|
||||||
|
angular.element(event.currentTarget).toggleClass("selected")
|
||||||
|
$scope.us.client_requirement = not $scope.us.client_requirement
|
||||||
|
|
||||||
return {link: link}
|
return {link: link}
|
||||||
|
|
||||||
|
@ -77,12 +147,10 @@ CreateBulkUserstroriesDirective = ($repo, $rs, $rootscope) ->
|
||||||
return {link: link}
|
return {link: link}
|
||||||
|
|
||||||
module = angular.module("taigaBacklog")
|
module = angular.module("taigaBacklog")
|
||||||
module.directive("tgLbCreateEditUserstory", ["$tgRepo", "$tgModel", CreateEditUserstoryDirective])
|
module.directive("tgLbCreateEditUserstory", ["$tgRepo", "$tgModel", "$tgResources", CreateEditUserstoryDirective])
|
||||||
module.directive("tgLbCreateBulkUserstories", [
|
module.directive("tgLbCreateBulkUserstories", [
|
||||||
"$tgRepo",
|
"$tgRepo",
|
||||||
"$tgResources",
|
"$tgResources",
|
||||||
"$rootScope",
|
"$rootScope",
|
||||||
CreateBulkUserstroriesDirective
|
CreateBulkUserstroriesDirective
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,8 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
subtitle = us.subject
|
subtitle = us.subject
|
||||||
|
|
||||||
@confirm.ask(title, subtitle).then =>
|
@confirm.ask(title, subtitle).then =>
|
||||||
console.log "#TODO"
|
@.repo.remove(us).then =>
|
||||||
|
@.loadBacklog()
|
||||||
|
|
||||||
addNewUs: (type) ->
|
addNewUs: (type) ->
|
||||||
switch type
|
switch type
|
||||||
|
@ -239,8 +240,6 @@ BacklogSprintDirective = ($repo) ->
|
||||||
#########################
|
#########################
|
||||||
|
|
||||||
linkCommon = ($scope, $el, $attrs, $ctrl) ->
|
linkCommon = ($scope, $el, $attrs, $ctrl) ->
|
||||||
$ctrl = $el.closest("div.wrapper").controller()
|
|
||||||
|
|
||||||
sprint = $scope.$eval($attrs.tgBacklogSprint)
|
sprint = $scope.$eval($attrs.tgBacklogSprint)
|
||||||
if $scope.$first
|
if $scope.$first
|
||||||
$el.addClass("sprint-current")
|
$el.addClass("sprint-current")
|
||||||
|
@ -331,7 +330,7 @@ BacklogSprintDirective = ($repo) ->
|
||||||
})
|
})
|
||||||
|
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
$ctrl = $el.controller()
|
$ctrl = $el.closest("div.wrapper").controller()
|
||||||
linkSortable($scope, $el, $attrs, $ctrl)
|
linkSortable($scope, $el, $attrs, $ctrl)
|
||||||
linkCommon($scope, $el, $attrs, $ctrl)
|
linkCommon($scope, $el, $attrs, $ctrl)
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,9 @@ class Model
|
||||||
return @._name
|
return @._name
|
||||||
|
|
||||||
getAttrs: (patch=false) ->
|
getAttrs: (patch=false) ->
|
||||||
|
if @._attrs.version?
|
||||||
|
@._modifiedAttrs.version = @._attrs.version
|
||||||
|
|
||||||
if patch
|
if patch
|
||||||
return _.extend({}, @._modifiedAttrs)
|
return _.extend({}, @._modifiedAttrs)
|
||||||
return _.extend({}, @._attrs, @._modifiedAttrs)
|
return _.extend({}, @._attrs, @._modifiedAttrs)
|
||||||
|
|
|
@ -111,5 +111,6 @@ module.run([
|
||||||
"$tgProjectsResourcesProvider",
|
"$tgProjectsResourcesProvider",
|
||||||
"$tgSprintsResourcesProvider",
|
"$tgSprintsResourcesProvider",
|
||||||
"$tgUserstoriesResourcesProvider",
|
"$tgUserstoriesResourcesProvider",
|
||||||
|
"$tgMdRenderResourcesProvider",
|
||||||
initResources
|
initResources
|
||||||
])
|
])
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
###
|
||||||
|
# Copyright (C) 2014 Andrey Antukh <niwi@niwi.be>
|
||||||
|
# Copyright (C) 2014 Jesús Espino Garcia <jespinog@gmail.com>
|
||||||
|
# Copyright (C) 2014 David Barragán Merino <bameda@dbarragan.com>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# File: modules/resources/mdrender.coffee
|
||||||
|
###
|
||||||
|
|
||||||
|
|
||||||
|
taiga = @.taiga
|
||||||
|
|
||||||
|
resourceProvider = ($repo, $urls, $http) ->
|
||||||
|
service = {}
|
||||||
|
|
||||||
|
service.render = (projectId, content) ->
|
||||||
|
# We can't use an empty content
|
||||||
|
content = ' ' if not content? or content == ""
|
||||||
|
|
||||||
|
params = {
|
||||||
|
project_id: projectId
|
||||||
|
content: content
|
||||||
|
}
|
||||||
|
url = $urls.resolve("wiki")
|
||||||
|
return $http.post("#{url}/render", params).then (data) =>
|
||||||
|
return data.data
|
||||||
|
|
||||||
|
return (instance) ->
|
||||||
|
instance.mdrender = service
|
||||||
|
|
||||||
|
|
||||||
|
module = angular.module("taigaResources")
|
||||||
|
module.factory("$tgMdRenderResourcesProvider", ["$tgRepo", "$tgUrls", "$tgHttp", resourceProvider])
|
|
@ -39,7 +39,7 @@
|
||||||
},
|
},
|
||||||
"us": {
|
"us": {
|
||||||
"title-new": "New User Story",
|
"title-new": "New User Story",
|
||||||
"team-requirement": "Ream Requirement",
|
"team-requirement": "Team Requirement",
|
||||||
"client-requirement": "Client Requirement"
|
"client-requirement": "Client Requirement"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,20 +13,24 @@ form
|
||||||
div.markdown-preview
|
div.markdown-preview
|
||||||
a.edit.active(href="", title="Edit") Edit
|
a.edit.active(href="", title="Edit") Edit
|
||||||
a.preview(href="", title="Preview") Preview
|
a.preview(href="", title="Preview") Preview
|
||||||
textarea(placeholder="One user story per line", ng-model="us.description")
|
textarea.description(placeholder="One user story per line", ng-model="us.description")
|
||||||
|
div.description-preview.hidden
|
||||||
div.new-us-settings
|
div.new-us-settings
|
||||||
fieldset
|
fieldset
|
||||||
label.requirement(for="team-requirement", tg-i18n="us.team-requirement")
|
label.requirement.team-requirement(for="team-requirement", tg-i18n="us.team-requirement")
|
||||||
input(
|
input(
|
||||||
type="checkbox", ng-model="us.team_requirement",
|
type="checkbox", ng-model="us.team_requirement",
|
||||||
name="team-requirement", id="team-requirement")
|
name="team-requirement", id="team-requirement")
|
||||||
fieldset
|
fieldset
|
||||||
label.requirement(for="client-requirement", tg-i18n="us.client-requirement")
|
label.requirement.client-requirement(for="client-requirement", tg-i18n="us.client-requirement")
|
||||||
input(
|
input(
|
||||||
type="checkbox", ng-model="us.client_requirement",
|
type="checkbox", ng-model="us.client_requirement",
|
||||||
name="client-requirement", id="client-requirement")
|
name="client-requirement", id="client-requirement")
|
||||||
fieldset
|
fieldset
|
||||||
label.blocked(for="blocked-us", tg-i18n="common.blocked")
|
label.blocked(for="blocked-us", tg-i18n="common.blocked")
|
||||||
input(type="checkbox", ng-model="us.blocked", name="blocked-us", id="blocked-us")
|
input(type="checkbox", ng-model="us.is_blocked", name="blocked-us", id="blocked-us")
|
||||||
|
fieldset.blocked-note.hidden
|
||||||
|
textarea(placeholder="Why is this user story blocked?", ng-model="us.blocked_note")
|
||||||
|
|
||||||
a.button.button-green(href="", title="Save")
|
a.button.button-green(href="", title="Save")
|
||||||
span Create
|
span Create
|
||||||
|
|
Loading…
Reference in New Issue