Refactoring navbar

stable
Alejandro Alonso 2015-04-17 09:53:31 +02:00 committed by Juanfran
parent 61d5f47157
commit 032aeb2280
27 changed files with 179 additions and 68 deletions

View File

@ -39,7 +39,10 @@ taiga.sessionId = taiga.generateUniqueSessionIdentifier()
configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $tgEventsProvider, tgLoaderProvider,
$compileProvider, $translateProvider) ->
$routeProvider.when("/",
{templateUrl: "project/projects.html", resolve: {loader: tgLoaderProvider.add()}})
{templateUrl: "home/home.html", resolve: {loader: tgLoaderProvider.add()}})
$routeProvider.when("/projects/",
{templateUrl: "projects/projects.html", resolve: {loader: tgLoaderProvider.add()}})
$routeProvider.when("/project/:pslug/",
{templateUrl: "project/project.html"})
@ -317,6 +320,8 @@ modules = [
"taigaEvents",
# Specific Modules
"taigaNavigationBar",
"taigaProjects",
"taigaRelatedTasks",
"taigaBacklog",
"taigaTaskboard",

View File

@ -44,6 +44,7 @@ module.directive("tgMain", ["$rootScope", "$window", TaigaMainDirective])
urls = {
"home": "/"
"projects": "/projects"
"error": "/error"
"not-found": "/not-found"
"permission-denied": "/permission-denied"

View File

@ -57,9 +57,7 @@ FeedbackDirective = ($lightboxService, $repo, $confirm, $loading)->
$el.on "submit", "form", submit
$scope.$on "feedback:show", ->
$scope.$apply ->
$scope.feedback = {}
$lightboxService.open($el)
$el.find("textarea").focus()

View File

@ -125,7 +125,15 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project
event.preventDefault()
lightboxService.close($el)
return {link:link}
directive = {
link: link,
templateUrl: "project/wizard-create-project.html"
scope: {}
}
return directive
module.directive("tgLbCreateProject", ["$rootScope", "$tgRepo", "$tgConfirm", "$location", "$tgNavUrls",
"$tgResources", "$projectUrl", "$tgLoading", "lightboxService", "$cacheFactory", "$translate", CreateProject])

View File

@ -34,10 +34,11 @@ class ProjectsController extends taiga.Controller
"$tgLocation",
"$appTitle",
"$projectUrl",
"$tgConfig",
"tgLoader"
]
constructor: (@scope, @q, @rs, @rootscope, @navUrls, @auth, @location, @appTitle, @projectUrl,
constructor: (@scope, @q, @rs, @rootscope, @navUrls, @auth, @location, @appTitle, @projectUrl, @config
tgLoader) ->
@appTitle.set("Projects")
@ -72,6 +73,12 @@ class ProjectsController extends taiga.Controller
@auth.logout()
@location.path(@navUrls.resolve("login"))
isFeedbackEnabled: ->
return @config.get("feedbackEnabled")
sendFeedback: ->
@rootscope.$broadcast("feedback:show")
module.controller("ProjectsController", ProjectsController)

View File

@ -40,6 +40,7 @@ urls = {
"stats": "/users/%s/stats"
# User - Notification
"permissions": "/permissions"
"notify-policies": "/notify-policies"
# User - Storage

View File

@ -37,7 +37,7 @@ resourceProvider = ($config, $repo, $http, $urls, $auth, $q, $translate) ->
return $repo.queryMany("projects")
service.listByMember = (memberId) ->
params = {"member": memberId}
params = {"member": memberId, "user_order": 1}
return $repo.queryMany("projects", params)
service.templates = ->
@ -54,6 +54,10 @@ resourceProvider = ($config, $repo, $http, $urls, $auth, $q, $translate) ->
service.stats = (projectId) ->
return $repo.queryOneRaw("projects", "#{projectId}/stats")
service.bulkUpdateOrder = (bulkData) ->
url = $urls.resolve("bulk-update-projects-order")
return $http.post(url, bulkData)
service.regenerate_userstories_csv_uuid = (projectId) ->
url = "#{$urls.resolve("projects")}/#{projectId}/regenerate_userstories_csv_uuid"
return $http.post(url)

View File

@ -15,10 +15,7 @@ html(lang="en")
//include partials/includes/modules/projects-nav
include partials/includes/components/notification-message
include partials/includes/modules/navigation-bar/navbar
//- the content of nav.menu is in coffe.modules.base TaigaMain directive
//nav.menu.hidden(tg-project-menu)
div(tg-navigation-bar)
div.master(ng-view)

View File

@ -1,3 +1,6 @@
a(href="#", title="Organizations")
include ../../../svg/organizations.svg
div.navbar-dropdown.dropdown-organization-list
ul
- for (var x = 0; x < 4; x++)

View File

@ -0,0 +1,14 @@
DropdownProjectListDirective = () ->
directive = {
templateUrl: "navigation-bar/dropdown-project-list/dropdown-project-list.html"
controller: "ProjectsController"
scope: {}
bindToController: true
controllerAs: "vm"
}
return directive
angular.module("taigaNavigationBar").directive("tgDropdownProjectList",
DropdownProjectListDirective)

View File

@ -0,0 +1,12 @@
a(href="", title="Projects")
include ../../../svg/projects.svg
div.navbar-dropdown.dropdown-project-list
ul
a(href="#",
ng-repeat="project in vm.projects.recents",
ng-bind="::project.name"
tg-nav="project:project=project.slug")
a.see-more-projects-btn.button-gray(tg-nav="projects", href="#", title="See more projects") See more
a.create-project-btn.button-green(href="#", ng-click="vm.newProject()", title="Create project") Create project

View File

@ -0,0 +1,13 @@
DropdownUserDirective = () ->
directive = {
templateUrl: "navigation-bar/dropdown-user/dropdown-user.html"
controller: "ProjectsController"
scope: {}
bindToController: true
controllerAs: "vm"
}
return directive
angular.module("taigaNavigationBar").directive("tgDropdownUser",
DropdownUserDirective)

View File

@ -0,0 +1,24 @@
a.user-avatar(href="#", title="{{ vm.user.full_name_display }}")
{{ vm.user.full_name_display }}
img(tg-bo-src="vm.user.photo", alt="{{ vm.user.full_name_display }}")
div.navbar-dropdown.dropdown-user
ul
li
a(href="#", title="{{ user.fullname }} profile") View Profile
li
a(href="#", tg-nav="user-settings-user-profile", title="Edit your profile") Edit Profile
li
a(href="#", tg-nav="user-settings-user-change-password", title="Change password") Change password
//li
// a(href="#", title="Edit your organizations") Edit Organizations
//li
// a(href="#", title="Edit your settings") Settings
li
a(href="#", tg-nav="user-settings-mail-notifications", title="Edit your notifications") Notifications
li(ng-show="vm.isFeedbackEnabled()")
a(ng-click="vm.sendFeedback()", href="#", title="Send feedback") Feedback
li
a(href="https://taiga.io/support/", target="_blank", title="Go to support") Help
li
a(href="#", ng-click="vm.logout()", title="Logout") Logout

View File

@ -0,0 +1,10 @@
NavigationBarDirective = () ->
directive = {
templateUrl: "navigation-bar/navigation-bar.html"
}
return directive
angular.module("taigaNavigationBar").directive("tgNavigationBar",
NavigationBarDirective)

View File

@ -0,0 +1,17 @@
nav.navbar
div.nav-left
a.logo(href="#", tg-nav="home", title="Dashboard")
include ../../svg/logo.svg
//a(href="#", title="Discover trending projects") Discover
a(href="https://taiga.io/support/", target="_blank", title="Taiga Support Page") Help
div.nav-right
a(href="", tg-nav="home", title="Dashboard")
include ../../svg/dashboard.svg
div.topnav-dropdown-wrapper(tg-dropdown-project-list)
//div.topnav-dropdown-wrapper(tg-dropdown-organization-list)
div.topnav-dropdown-wrapper(tg-dropdown-user)
div.wizard-create-project(tg-lb-create-project)

View File

@ -0,0 +1 @@
angular.module("taigaNavigationBar", [])

View File

@ -0,0 +1,40 @@
ProjectsListingDirective = ($rs) ->
link = (scope, el, attrs, ctrl) ->
itemEl = null
tdom = el.find(".js-sortable")
tdom.sortable({
dropOnEmpty: true
revert: 200
axis: "y"
})
tdom.on "sortstop", (event, ui) ->
itemEl = ui.item
project = itemEl.scope().project
index = itemEl.index()
scope.sorted_project_ids = _.without(scope.sorted_project_ids, project.id)
scope.sorted_project_ids.splice(index, 0, project.id)
sortData = []
for value, index in scope.sorted_project_ids
sortData.push({"project_id": value, "order":index})
$rs.projects.bulkUpdateOrder(sortData)
scope.$watch "vm.projects", (projects) =>
if projects?
scope.sorted_project_ids = _.map(projects.all, (p) -> p.id)
directive = {
templateUrl: "projects/listing/listing.html"
controller: "ProjectsController"
scope: {}
bindToController: true
controllerAs: "vm"
link: link
}
return directive
angular.module("taigaProjects").directive("tgProjectsListing",
["$tgResources", ProjectsListingDirective])

View File

@ -0,0 +1,11 @@
a.create-project-btn.button-green(href="#", ng-click="vm.newProject()", title="Create project") Create project
h2 Esto es sortable y persiste en el servidor! ;)
ul.js-sortable
li(tg-bind-scope, ng-repeat="project in vm.projects.all")
span Private: {{project.is_private}}, tags: {{project.tags}}, link:
a(href="#",
ng-bind="::project.name"
tg-nav="project:project=project.slug")

View File

@ -0,0 +1 @@
div(tg-projects-listing)

View File

@ -0,0 +1 @@
angular.module("taigaProjects", [])

View File

@ -1,7 +0,0 @@
div.navbar-dropdown.dropdown-project-list
ul
- for (var x = 0; x < 9; x++)
li
a(href="#", title="{{ project.title }}") Project 1
a.see-more-projects-btn.button-gray(href="#", title="See more projects") See more
a.create-project-btn.button-green(href="#", title="Create project") Create project

View File

@ -1,18 +0,0 @@
div.navbar-dropdown.dropdown-user
ul
li
a(href="#", title="{{ user.fullname }} profile") View Profile
li
a(href="#", tg-nav="user-settings-user-profile", title="Edit your profile") Edit Profile
li
a(href="#", title="Edit your organizations") Edit Organizations
li
a(href="#", title="Edit your settings") Settings
li
a(href="#", tg-nav="user-settings-mail-notifications", title="Edit your notifications") Notifications
li
a(href="#", title="Send feedback") Feedback
li
a(href="#", title="Go to support") Help
li
a(href="#", title="Logout") Logout

View File

@ -1,24 +0,0 @@
nav.navbar
div.nav-left
a.logo(href="#", title="Dashboard")
include ../../../../svg/logo.svg
a(href="#", title="Discover trending projects") Discover
a(href="#", title="Taiga Support Page") Help
div.nav-right
a(href="", title="Dashboard")
include ../../../../svg/dashboard.svg
div.topnav-dropdown-wrapper
a(href="", title="Projects")
include ../../../../svg/projects.svg
include dropdown-project-list
div.topnav-dropdown-wrapper
a(href="#", title="Organizations")
include ../../../../svg/organizations.svg
include dropdown-organization-list
div.topnav-dropdown-wrapper
a.user-avatar(href="#", title="{{ user.fullname }} profile")
span Sebastián Sanchís
img(src="https://s3.amazonaws.com/uifaces/faces/twitter/brad_frost/128.jpg", alt="{{ user.fullname }} picture")
include dropdown-user

View File

@ -1,8 +0,0 @@
.projects-nav-overlay
div.container
p(translate="COMMON.LOADING_PROJECT")
div.wizard-create-project(tg-lb-create-project)
include wizard-create-project
nav.projects-nav(tg-projects-nav)