mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-19 13:54:25 +01:00
inteface to display spaces
This commit is contained in:
parent
da95e6e0d8
commit
73a5689140
@ -234,7 +234,7 @@ Application.Controllers.controller "EditMachineController", ["$scope", '$state',
|
||||
Application.Controllers.controller "ShowMachineController", ['$scope', '$state', '$uibModal', '$stateParams', '_t', 'Machine', 'growl', 'machinePromise', 'dialogs'
|
||||
, ($scope, $state, $uibModal, $stateParams, _t, Machine, growl, machinePromise, dialogs) ->
|
||||
|
||||
## Retrieve the details for the machine id in the URL, if an error occurs redirect the user to the machines list
|
||||
## Retrieve the details for the machine id in the URL, if an error occurs redirect the user to the machines list
|
||||
$scope.machine = machinePromise
|
||||
|
||||
##
|
||||
|
@ -71,32 +71,12 @@ class SpacesController
|
||||
else
|
||||
$scope.space.space_files_attributes.splice(index, 1)
|
||||
|
||||
##
|
||||
# Manages the transition when a user clicks on the reservation button.
|
||||
# According to the status of user currently logged into the system, redirect him to the reservation page,
|
||||
# or display a modal window asking him to login or to create an account.
|
||||
# @param space {{id:number}} An object containg the id of the space to book,
|
||||
# the object will be completed before the fonction returns.
|
||||
# @param e {Object} see https://docs.angularjs.org/guide/expression#-event-
|
||||
##
|
||||
_reserveSpace = (space, e) ->
|
||||
_this = this
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
# if a user is authenticated ...
|
||||
if _this.$scope.isAuthenticated()
|
||||
_this.$state.go('app.logged.space_reserve', { id: space.id })
|
||||
# if the user is not logged, open the login modal window
|
||||
else
|
||||
_this.$scope.login()
|
||||
|
||||
|
||||
|
||||
##
|
||||
# Controller used in the public listing page, allowing everyone to see the list of spaces
|
||||
##
|
||||
Application.Controllers.controller "SpacesController", ["$scope", "$state", 'spacesPromise', ($scope, $state, spacesPromise) ->
|
||||
Application.Controllers.controller 'SpacesController', ['$scope', '$state', 'spacesPromise', ($scope, $state, spacesPromise) ->
|
||||
|
||||
## Retrieve the list of spaces
|
||||
$scope.spaces = spacesPromise
|
||||
@ -110,9 +90,8 @@ Application.Controllers.controller "SpacesController", ["$scope", "$state", 'spa
|
||||
##
|
||||
# Callback to book a reservation for the current space
|
||||
##
|
||||
$scope.reserveSpace = _reserveSpace.bind
|
||||
$scope: $scope
|
||||
$state: $state
|
||||
$scope.reserveSpace = (space) ->
|
||||
$state.go('app.logged.space_reserve', { id: space.slug })
|
||||
]
|
||||
|
||||
|
||||
@ -120,7 +99,7 @@ Application.Controllers.controller "SpacesController", ["$scope", "$state", 'spa
|
||||
##
|
||||
# Controller used in the space creation page (admin)
|
||||
##
|
||||
Application.Controllers.controller "NewSpaceController", ["$scope", "$state", 'CSRF',($scope, $state, CSRF) ->
|
||||
Application.Controllers.controller 'NewSpaceController', ['$scope', '$state', 'CSRF',($scope, $state, CSRF) ->
|
||||
CSRF.setMetaTags()
|
||||
|
||||
## API URL where the form will be posted
|
||||
@ -135,4 +114,41 @@ Application.Controllers.controller "NewSpaceController", ["$scope", "$state", 'C
|
||||
|
||||
## Using the SpacesController
|
||||
new SpacesController($scope, $state)
|
||||
]
|
||||
|
||||
Application.Controllers.controller 'ShowSpaceController', ['$scope', '$state', 'spacePromise', '_t', 'dialogs', ($scope, $state, spacePromise, _t, dialogs) ->
|
||||
|
||||
## Details of the space witch id/slug is provided in the URL
|
||||
$scope.space = spacePromise
|
||||
|
||||
##
|
||||
# Callback to book a reservation for the current space
|
||||
# @param event {Object} see https://docs.angularjs.org/guide/expression#-event-
|
||||
##
|
||||
$scope.reserveSpace = (event) ->
|
||||
event.preventDefault()
|
||||
$state.go('app.logged.space_reserve', { id: $scope.space.slug })
|
||||
|
||||
##
|
||||
# Callback to book a reservation for the current space
|
||||
# @param event {Object} see https://docs.angularjs.org/guide/expression#-event-
|
||||
##
|
||||
$scope.deleteSpace = (event) ->
|
||||
event.preventDefault()
|
||||
# check the permissions
|
||||
if $scope.currentUser.role isnt 'admin'
|
||||
console.error _t('space_show.unauthorized_operation')
|
||||
else
|
||||
dialogs.confirm
|
||||
resolve:
|
||||
object: ->
|
||||
title: _t('space_show.confirmation_required')
|
||||
msg: _t('space_show.do_you_really_want_to_delete_this_space')
|
||||
, -> # deletion confirmed
|
||||
# delete the machine then redirect to the machines listing
|
||||
$scope.space.$delete ->
|
||||
$state.go('app.public.machines_list')
|
||||
, (error)->
|
||||
growl.warning(_t('space_show.the_space_cant_be_deleted_because_it_is_already_reserved_by_some_users'))
|
||||
##
|
||||
]
|
@ -394,7 +394,7 @@ angular.module('application.router', ['ui.router']).
|
||||
url: '/spaces'
|
||||
views:
|
||||
'main@':
|
||||
templateUrl: '<%= asset_path "spaces/index.html.erb" %>'
|
||||
templateUrl: '<%= asset_path "spaces/index.html" %>'
|
||||
controller: 'SpacesController'
|
||||
resolve:
|
||||
spacesPromise: ['Space', (Space)->
|
||||
@ -403,6 +403,19 @@ angular.module('application.router', ['ui.router']).
|
||||
translations: [ 'Translations', (Translations) ->
|
||||
Translations.query(['app.public.spaces_list']).$promise
|
||||
]
|
||||
.state 'app.public.space_show',
|
||||
url: '/spaces/:id'
|
||||
views:
|
||||
'main@':
|
||||
templateUrl: '<%= asset_path "spaces/show.html" %>'
|
||||
controller: 'ShowSpaceController'
|
||||
resolve:
|
||||
spacePromise: ['Space', '$stateParams', (Space, $stateParams)->
|
||||
Space.get(id: $stateParams.id).$promise
|
||||
]
|
||||
translations: [ 'Translations', (Translations) ->
|
||||
Translations.query(['app.public.space_show']).$promise
|
||||
]
|
||||
.state 'app.logged.space_reserve',
|
||||
url: '/spaces/:id/reserve'
|
||||
.state 'app.admin.space_new',
|
||||
|
85
app/assets/templates/spaces/show.html
Normal file
85
app/assets/templates/spaces/show.html
Normal file
@ -0,0 +1,85 @@
|
||||
<div>
|
||||
|
||||
<section class="heading b-b">
|
||||
<div class="row no-gutter">
|
||||
<div class="col-xs-2 col-sm-2 col-md-1">
|
||||
<section class="heading-btn">
|
||||
<a href="#" ng-click="backPrevLocation($event)"><i class="fa fa-long-arrow-left "></i></a>
|
||||
</section>
|
||||
</div>
|
||||
<div class="col-xs-10 col-sm-10 col-md-7 b-l b-r-md">
|
||||
<section class="heading-title">
|
||||
<h1>{{ space.name }}</h1>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-sm-12 col-md-4 b-t hide-b-md">
|
||||
<section class="heading-actions wrapper">
|
||||
<a ng-click="reserveSpace($event)" class="btn btn-lg btn-warning bg-white b-2x rounded m-t-xs" ng-if="!isAuthorized('admin')" translate>{{ 'space_show.book_this_space' }}</a>
|
||||
|
||||
<a ui-sref="app.admin.space_edit({id: space.slug})" ng-if="isAuthorized('admin')" class="btn btn-lg btn-warning bg-white b-2x rounded m-t-xs"><i class="fa fa-edit"></i> {{ 'edit' | translate }}</a>
|
||||
<a ng-click="deleteSpace($event)" ng-if="isAuthorized('admin')" class="btn btn-lg btn-danger b-2x rounded no-b m-t-xs"><i class="fa fa-trash-o"></i></a>
|
||||
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="row no-gutter">
|
||||
<div class="col-sm-12 col-md-12 col-lg-8 b-r-lg">
|
||||
|
||||
<div class="article wrapper-lg" >
|
||||
|
||||
<div class="article-thumbnail" ng-if="space.space_image">
|
||||
<img ng-src="{{space.space_image}}" alt="{{space.name}}" class="img-responsive">
|
||||
</div>
|
||||
|
||||
<p class="intro" ng-bind-html="space.description | toTrusted"></p>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 col-md-12 col-lg-4">
|
||||
|
||||
<div class="widget panel b-a m m-t-lg">
|
||||
<div class="panel-heading b-b small">
|
||||
<h3 translate>{{ 'space_show.characteristics' }}</h3>
|
||||
</div>
|
||||
<div class="widget-content no-bg wrapper">
|
||||
<h3></h3>
|
||||
<p ng-bind-html="space.characteristics | toTrusted"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="widget panel b-a m" ng-if="space.space_files_attributes">
|
||||
<div class="panel-heading b-b">
|
||||
<span class="badge bg-warning pull-right">{{space.space_files_attributes.length}}</span>
|
||||
<h3 translate>{{ 'space_show.files_to_download' }}</h3>
|
||||
</div>
|
||||
|
||||
<ul class="widget-content list-group list-group-lg no-bg auto">
|
||||
<li ng-repeat="file in space.space_files_attributes" class="list-group-item no-b clearfix">
|
||||
<a target="_blank" ng-href="{{file.attachment_url}}"><i class="fa fa-arrow-circle-o-down"> </i> {{file.attachment | humanize : 25}}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section class="widget panel b-a m" ng-if="space.space_projects">
|
||||
<div class="panel-heading b-b">
|
||||
<h3 translate>{{ 'space_show.projects_using_the_space' }}</h3>
|
||||
</div>
|
||||
|
||||
<ul class="widget-content list-group list-group-lg no-bg auto">
|
||||
<li ng-repeat="project in space.space_projects" class="list-group-item no-b clearfix">
|
||||
<a ui-sref="app.public.projects_show({id:project.slug})"><i class="fa"> </i> {{project.name}}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
@ -4,4 +4,7 @@ json.space_files_attributes @space.space_files do |f|
|
||||
json.id f.id
|
||||
json.attachment f.attachment_identifier
|
||||
json.attachment_url f.attachment_url
|
||||
end
|
||||
json.space_projects @space.projects do |p|
|
||||
json.extract! p, :slug, :name
|
||||
end
|
@ -256,4 +256,16 @@ en:
|
||||
spaces_list:
|
||||
# list of spaces
|
||||
the_spaces: "The spaces"
|
||||
add_a_space: "Add a space"
|
||||
add_a_space: "Add a space"
|
||||
|
||||
space_show:
|
||||
# display the details of a space
|
||||
space_show:
|
||||
book_this_space: "Book this space"
|
||||
unauthorized_operation: "Unauthorized operation"
|
||||
confirmation_required: "Confirmation required"
|
||||
do_you_really_want_to_delete_this_space: "Do you really want to delete this space?"
|
||||
the_space_cant_be_deleted_because_it_is_already_reserved_by_some_users: "Unable to delete this space, because it is already reserved by some users."
|
||||
characteristics: "Characteristics"
|
||||
files_to_download: "Files to download"
|
||||
projects_using_the_space: "Projects using the space"
|
@ -259,3 +259,15 @@ fr:
|
||||
# liste des espaces
|
||||
the_spaces: "Les espaces"
|
||||
add_a_space: "Ajouter un espace"
|
||||
|
||||
space_show:
|
||||
# affichage des détails d'un espace
|
||||
space_show:
|
||||
book_this_space: "Réserver cet espace"
|
||||
unauthorized_operation: "Opération non autorisée"
|
||||
confirmation_required: "Confirmation requise"
|
||||
do_you_really_want_to_delete_this_space: "Voulez-vous vraiment supprimer cet espace ?"
|
||||
the_space_cant_be_deleted_because_it_is_already_reserved_by_some_users: "L'espace ne peut pas être supprimé car il a déjà été réservé par des utilisateurs."
|
||||
characteristics: "Caractéristiques"
|
||||
files_to_download: "Fichiers à télécharger"
|
||||
projects_using_the_space: "Projets utilisant l'espace"
|
||||
|
Loading…
x
Reference in New Issue
Block a user