1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

space edition interface

This commit is contained in:
Sylvain 2017-02-14 13:36:10 +01:00
parent d8acd4c86f
commit 0adb9e29c6
11 changed files with 245 additions and 149 deletions

View File

@ -116,6 +116,26 @@ Application.Controllers.controller 'NewSpaceController', ['$scope', '$state', 'C
new SpacesController($scope, $state)
]
##
# Controller used in the space edition page (admin)
##
Application.Controllers.controller 'EditSpaceController', ['$scope', '$state', '$stateParams', 'spacePromise', 'CSRF',($scope, $state, $stateParams, spacePromise, CSRF) ->
CSRF.setMetaTags()
## API URL where the form will be posted
$scope.actionUrl = "/api/spaces/" + $stateParams.id
## Form action on the above URL
$scope.method = "put"
## space to modify
$scope.space = spacePromise
## Using the SpacesController
new SpacesController($scope, $state)
]
Application.Controllers.controller 'ShowSpaceController', ['$scope', '$state', 'spacePromise', '_t', 'dialogs', 'growl', ($scope, $state, spacePromise, _t, dialogs, growl) ->
## Details of the space witch id/slug is provided in the URL

View File

@ -426,6 +426,19 @@ angular.module('application.router', ['ui.router']).
translations: [ 'Translations', (Translations) ->
Translations.query(['app.public.space_show']).$promise
]
.state 'app.admin.space_edit',
url: '/spaces/:id/edit'
views:
'main@':
templateUrl: '<%= asset_path "spaces/edit.html" %>'
controller: 'EditSpaceController'
resolve:
spacePromise: ['Space', '$stateParams', (Space, $stateParams)->
Space.get(id: $stateParams.id).$promise
]
translations: [ 'Translations', (Translations) ->
Translations.query(['app.admin.space_edit', 'app.shared.space']).$promise
]
.state 'app.logged.space_reserve',
url: '/spaces/:id/reserve'

View File

@ -1,134 +1,109 @@
<form role="form"
name="spaceForm"
class="form-horizontal"
action="{{ actionUrl }}"
ng-upload="submited(content)"
upload-options-enable-rails-csrf="true"
unsaved-warning-form
novalidate>
<uib-alert ng-repeat="alert in alerts" type="{{alert.type}}" close="closeAlert($index)">{{alert.msg}}</uib-alert>
<input name="_method" type="hidden" ng-value="method">
<div class="form-group m-b-lg" ng-class="{'has-error': spaceForm['space[name]'].$dirty && spaceForm['space[name]'].$invalid}">
<label for="space_name" class="col-sm-2 control-label">{{ 'space.name' | translate }} *</label>
<div class="col-sm-4">
<input ng-model="space.name"
type="text"
name="space[name]"
class="form-control"
id="space_name"
placeholder="{{'space.name' | translate}}"
required>
<span class="help-block" ng-show="spaceForm['space[name]'].$dirty && spaceForm['space[name]'].$error.required" translate>{{ 'space.name_is_required' }}</span>
</div>
</div>
<section class="panel panel-default bg-light m-lg">
<div class="panel-body m-r">
<uib-alert ng-repeat="alert in alerts" type="{{alert.type}}" close="closeAlert($index)">{{alert.msg}}</uib-alert>
<div class="form-group m-b-lg" ng-class="{'has-error': spaceForm['space[name]'].$dirty && spaceForm['space[name]'].$invalid}">
<label for="space_name" class="col-sm-2 control-label">{{ 'space.name' | translate }} *</label>
<div class="col-sm-4">
<input ng-model="space.name"
type="text"
name="space[name]"
class="form-control"
id="space_name"
placeholder="{{'space.name' | translate}}"
required>
<span class="help-block" ng-show="spaceForm['space[name]'].$dirty && spaceForm['space[name]'].$error.required" translate>{{ 'space.name_is_required' }}</span>
</div>
<div class="form-group m-b-lg">
<label for="space_image" class="col-sm-2 control-label">{{ 'space.illustration' | translate }} *</label>
<div class="col-sm-10">
<div class="fileinput" data-provides="fileinput" ng-class="fileinputClass(space.space_image)">
<div class="fileinput-new thumbnail" style="width: 334px; height: 250px;">
<img src="data:image/png;base64," data-src="holder.js/100%x100%/text:&#xf03e;/font:FontAwesome/icon" bs-holder ng-if="!space.space_image">
</div>
<div class="form-group m-b-lg">
<label for="space_image" class="col-sm-2 control-label">{{ 'space.illustration' | translate }} *</label>
<div class="col-sm-10">
<div class="fileinput" data-provides="fileinput" ng-class="fileinputClass(space.space_image)">
<div class="fileinput-new thumbnail" style="width: 334px; height: 250px;">
<img src="data:image/png;base64," data-src="holder.js/100%x100%/text:&#xf03e;/font:FontAwesome/icon" bs-holder ng-if="!space.space_image">
</div>
<div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 334px;">
<img ng-src="{{ space.space_image }}" alt="" />
</div>
<div>
<span class="btn btn-default btn-file">
<span class="fileinput-new">{{ 'space.add_an_illustration' | translate }} <i class="fa fa-upload fa-fw"></i></span>
<span class="fileinput-exists" translate>{{ 'change' }}</span>
<input type="file"
id="space_image"
ng-model="space.space_image"
name="space[space_image_attributes][attachment]"
accept="image/*"
required
bs-jasny-fileinput>
</span>
<a href="#" class="btn btn-danger fileinput-exists" data-dismiss="fileinput" translate>{{ 'delete' }}</a>
</div>
</div>
</div>
<div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 334px;">
<img ng-src="{{ space.space_image }}" alt="" />
</div>
<div class="form-group m-b-xl" ng-class="{'has-error': spaceForm['space[default_places]'].$dirty && spaceForm['space[default_places]'].$invalid}">
<label for="default_places" class="col-sm-2 control-label">{{ 'space.default_places' | translate }} *</label>
<div class="col-sm-10">
<input type="number"
name="space[default_places]"
ng-model="space.default_places"
id="default_places"
class="form-control"
required>
<span class="help-block" ng-show="spaceForm['space[default_places]'].$dirty && spaceForm['space[default_places]'].$error.required" translate>{{ 'space.default_places_is_required' }}</span>
</div>
<div>
<span class="btn btn-default btn-file">
<span class="fileinput-new">{{ 'space.add_an_illustration' | translate }} <i class="fa fa-upload fa-fw"></i></span>
<span class="fileinput-exists" translate>{{ 'change' }}</span>
<input type="file"
id="space_image"
ng-model="space.space_image"
name="space[space_image_attributes][attachment]"
accept="image/*"
required
bs-jasny-fileinput>
</span>
<a href="#" class="btn btn-danger fileinput-exists" data-dismiss="fileinput" translate>{{ 'delete' }}</a>
</div>
<div class="form-group m-b-xl">
<label for="space_description" class="col-sm-2 control-label" translate>{{ 'space.description' }}</label>
<div class="col-sm-10">
<input type="hidden"
name="space[description]"
ng-value="space.description" />
<summernote ng-model="space.description"
id="space_description"
placeholder=""
config="summernoteOpts"
name="space[description]">
</summernote>
</div>
</div>
<div class="form-group m-b-xl">
<label for="space_characteristics" class="col-sm-2 control-label" translate>{{ 'space.characteristics' }}</label>
<div class="col-sm-10">
<input type="hidden"
name="space[characteristics]"
ng-value="space.characteristics" />
<summernote ng-model="space.characteristics"
id="space_characteristics"
placeholder=""
config="summernoteOpts"
name="space[characteristics]">
</summernote>
</div>
</div>
<div class="form-group m-b-xl">
<label class="col-sm-2 control-label" translate>{{ 'space.attached_files_(pdf)' }}</label>
<div class="col-sm-10">
<div ng-repeat="file in space.space_files_attributes" ng-show="!file._destroy">
<input type="hidden" ng-model="file.id" name="space[space_files_attributes][][id]" ng-value="file.id" />
<input type="hidden" ng-model="file._destroy" name="space[space_files_attributes][][_destroy]" ng-value="file._destroy"/>
<div class="fileinput input-group" data-provides="fileinput" ng-class="fileinputClass(file.attachment)">
<div class="form-control" data-trigger="fileinput">
<i class="glyphicon glyphicon-file fileinput-exists"></i> <span class="fileinput-filename">{{file.attachment}}</span>
</div>
<span class="input-group-addon btn btn-default btn-file"><span class="fileinput-new" translate>{{ 'space.attach_a_file' }}</span>
<span class="fileinput-exists" translate>{{ 'change' }}</span><input type="file" name="space[space_files_attributes][][attachment]" accept=".pdf"></span>
<a class="input-group-addon btn btn-danger fileinput-exists" data-dismiss="fileinput" ng-click="deleteFile(file)"><i class="fa fa-trash-o"></i></a>
</div>
</div>
<a class="btn btn-default" ng-click="addFile()" role="button"> {{ 'space.add_an_attachment' | translate }} <i class="fa fa-file-o fa-fw"></i></a>
</div>
</div>
</div> <!-- ./panel-body -->
<div class="panel-footer no-padder">
<input type="submit"
value="{{ 'space.add_this_space' | translate }}"
class="r-b btn-valid btn btn-warning btn-block p-lg btn-lg text-u-c"
ng-disabled="spaceForm.$invalid"/>
</div>
</section>
</form>
</div>
</div>
<div class="form-group m-b-xl" ng-class="{'has-error': spaceForm['space[default_places]'].$dirty && spaceForm['space[default_places]'].$invalid}">
<label for="default_places" class="col-sm-2 control-label">{{ 'space.default_places' | translate }} *</label>
<div class="col-sm-10">
<input type="number"
name="space[default_places]"
ng-model="space.default_places"
id="default_places"
class="form-control"
required>
<span class="help-block" ng-show="spaceForm['space[default_places]'].$dirty && spaceForm['space[default_places]'].$error.required" translate>{{ 'space.default_places_is_required' }}</span>
</div>
</div>
<div class="form-group m-b-xl">
<label for="space_description" class="col-sm-2 control-label" translate>{{ 'space.description' }}</label>
<div class="col-sm-10">
<input type="hidden"
name="space[description]"
ng-value="space.description" />
<summernote ng-model="space.description"
id="space_description"
placeholder=""
config="summernoteOpts"
name="space[description]">
</summernote>
</div>
</div>
<div class="form-group m-b-xl">
<label for="space_characteristics" class="col-sm-2 control-label" translate>{{ 'space.characteristics' }}</label>
<div class="col-sm-10">
<input type="hidden"
name="space[characteristics]"
ng-value="space.characteristics" />
<summernote ng-model="space.characteristics"
id="space_characteristics"
placeholder=""
config="summernoteOpts"
name="space[characteristics]">
</summernote>
</div>
</div>
<div class="form-group m-b-xl">
<label class="col-sm-2 control-label" translate>{{ 'space.attached_files_(pdf)' }}</label>
<div class="col-sm-10">
<div ng-repeat="file in space.space_files_attributes" ng-show="!file._destroy">
<input type="hidden" ng-model="file.id" name="space[space_files_attributes][][id]" ng-value="file.id" />
<input type="hidden" ng-model="file._destroy" name="space[space_files_attributes][][_destroy]" ng-value="file._destroy"/>
<div class="fileinput input-group" data-provides="fileinput" ng-class="fileinputClass(file.attachment)">
<div class="form-control" data-trigger="fileinput">
<i class="glyphicon glyphicon-file fileinput-exists"></i> <span class="fileinput-filename">{{file.attachment}}</span>
</div>
<span class="input-group-addon btn btn-default btn-file"><span class="fileinput-new" translate>{{ 'space.attach_a_file' }}</span>
<span class="fileinput-exists" translate>{{ 'change' }}</span><input type="file" name="space[space_files_attributes][][attachment]" accept=".pdf"></span>
<a class="input-group-addon btn btn-danger fileinput-exists" data-dismiss="fileinput" ng-click="deleteFile(file)"><i class="fa fa-trash-o"></i></a>
</div>
</div>
<a class="btn btn-default" ng-click="addFile()" role="button"> {{ 'space.add_an_attachment' | translate }} <i class="fa fa-file-o fa-fw"></i></a>
</div>
</div>

View File

@ -0,0 +1,50 @@
<section class="heading b-b">
<div class="row no-gutter">
<div class="col-md-1 hidden-xs">
<section class="heading-btn">
<a href="#" ng-click="backPrevLocation($event)"><i class="fa fa-long-arrow-left "></i></a>
</section>
</div>
<div class="col-md-8 b-l b-r">
<section class="heading-title">
<h1 translate translate-values="{NAME: space.name}">{{ 'space_edit.edit_the_space_NAME' }}</h1>
</section>
</div>
</div>
</section>
<div class="row no-gutter" >
<div class="col-md-9 b-r nopadding">
<form role="form"
name="spaceForm"
class="form-horizontal"
action="{{ actionUrl }}"
ng-upload="submited(content)"
upload-options-enable-rails-csrf="true"
unsaved-warning-form
novalidate>
<input name="_method" type="hidden" ng-value="method">
<section class="panel panel-default bg-light m-lg">
<div class="panel-body m-r">
<ng-include src="'<%= asset_path 'spaces/_form.html' %>'"></ng-include>
</div>
<div class="panel-footer no-padder">
<input type="submit"
value="{{ 'space_edit.validate_the_changes' | translate }}"
class="r-b btn-valid btn btn-warning btn-block p-lg btn-lg text-u-c"
ng-disabled="spaceForm.$invalid"/>
</div>
</section>
</form>
</div>
<div class="col-md-3"/>
</div>

View File

@ -7,7 +7,7 @@
</div>
<div class="col-md-8 b-l b-r">
<section class="heading-title">
<h1 translate>{{ 'add_a_new_space' }}</h1>
<h1 translate>{{ 'space_new.add_a_new_space' }}</h1>
</section>
</div>
@ -22,11 +22,35 @@
<div class="col-md-9 b-r nopadding">
<div class="m-lg alert alert-warning" role="alert">
{{ 'watch_out_when_creating_a_new_space_its_prices_are_initialized_at_0_for_all_subscriptions' | translate}}
{{ 'consider_changing_its_prices_before_creating_any_reservation_slot' | translate }}
{{ 'space_new.watch_out_when_creating_a_new_space_its_prices_are_initialized_at_0_for_all_subscriptions' | translate}}
{{ 'space_new.consider_changing_its_prices_before_creating_any_reservation_slot' | translate }}
</div>
<ng-include src="'<%= asset_path 'spaces/_form.html' %>'"></ng-include>
<form role="form"
name="spaceForm"
class="form-horizontal"
action="{{ actionUrl }}"
ng-upload="submited(content)"
upload-options-enable-rails-csrf="true"
unsaved-warning-form
novalidate>
<input name="_method" type="hidden" ng-value="method">
<section class="panel panel-default bg-light m-lg">
<div class="panel-body m-r">
<ng-include src="'<%= asset_path 'spaces/_form.html' %>'"></ng-include>
</div>
<div class="panel-footer no-padder">
<input type="submit"
value="{{ 'space_new.add_this_space' | translate }}"
class="r-b btn-valid btn btn-warning btn-block p-lg btn-lg text-u-c"
ng-disabled="spaceForm.$invalid"/>
</div>
</section>
</form>
</div>
<div class="col-md-3"/>

View File

@ -17,7 +17,7 @@
<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 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>
@ -28,7 +28,7 @@
<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 wrapper-lg">
<div class="article-thumbnail" ng-if="space.space_image">
<img ng-src="{{space.space_image}}" alt="{{space.name}}" class="img-responsive">

View File

@ -1,4 +1,4 @@
json.extract! @space, :id, :name, :description, :characteristics, :created_at, :updated_at
json.extract! @space, :id, :name, :description, :characteristics, :created_at, :updated_at, :slug, :default_places
json.space_image @space.space_image.attachment.large.url if @space.space_image
json.space_files_attributes @space.space_files do |f|
json.id f.id

View File

@ -69,12 +69,6 @@ en:
beware_when_creating_a_training_its_reservation_prices_are_initialized_to_zero: "Beware, when creating a training, its reservation prices are initialized at zero."
dont_forget_to_change_them_before_creating_slots_for_this_training: "Don't forget to change them before creating slots for this training."
space_new:
# create a new space
add_a_new_space: "Add a new space"
watch_out_when_creating_a_new_space_its_prices_are_initialized_at_0_for_all_subscriptions: "Watch out! When creating a new space, its prices are initialized at 0 for all subscriptions."
consider_changing_its_prices_before_creating_any_reservation_slot: "Consider changing its prices before creating any reservation slot."
events:
# events tracking and management
events_monitoring: "Events monitoring"
@ -581,3 +575,17 @@ en:
client_successfully_updated: "Client successfully updated."
client_successfully_deleted: "Client successfully deleted."
access_successfully_revoked: "Access successfully revoked."
space_new:
# create a new space
space_new:
add_a_new_space: "Add a new space"
watch_out_when_creating_a_new_space_its_prices_are_initialized_at_0_for_all_subscriptions: "Watch out! When creating a new space, its prices are initialized at 0 for all subscriptions."
consider_changing_its_prices_before_creating_any_reservation_slot: "Consider changing its prices before creating any reservation slot."
add_this_space: "Add this space"
space_edit:
# modify an exiting space
space_edit:
edit_the_space_NAME: "Edit the space: {{NAME}}" # angular interpolation
validate_the_changes: "Validate the changes"

View File

@ -69,12 +69,6 @@ fr:
beware_when_creating_a_training_its_reservation_prices_are_initialized_to_zero: "Attention, lors de la création d'une formation, ses tarifs de réservation sont initialisés à zero."
dont_forget_to_change_them_before_creating_slots_for_this_training: "Pensez à les modifier avant de créer des créneaux pour cette formation."
space_new:
# créer un nouvel espace
add_a_new_space: "Ajouter un nouvel espace"
watch_out_when_creating_a_new_space_its_prices_are_initialized_at_0_for_all_subscriptions: "Attention, lors de la création d'un espace, ses tarifs de réservation sont initialisés à zero pour tout les abonnements."
consider_changing_its_prices_before_creating_any_reservation_slot: "Pensez à modifier ces prix avant de créer des créneaux pour cet espace."
events:
# gestion et suivi des évènements
events_monitoring: "Suivi des évènements"
@ -581,3 +575,17 @@ fr:
client_successfully_updated: "Les modifications ont été enregistrées."
client_successfully_deleted: "Le compte client a bien été supprimé."
access_successfully_revoked: "L'accès a bien été revoqué."
space_new:
# créer un nouvel espace
space_new:
add_a_new_space: "Ajouter un nouvel espace"
watch_out_when_creating_a_new_space_its_prices_are_initialized_at_0_for_all_subscriptions: "Attention, lors de la création d'un espace, ses tarifs de réservation sont initialisés à zero pour tout les abonnements."
consider_changing_its_prices_before_creating_any_reservation_slot: "Pensez à modifier ces prix avant de créer des créneaux pour cet espace."
add_this_space: "Ajouter cet espace"
space_edit:
# modifier un espace existant
space_edit:
edit_the_space_NAME: "Modifier l'espace : {{NAME}}" # angular interpolation
validate_the_changes: "Valider les modifications"

View File

@ -396,6 +396,5 @@ en:
attached_files_(pdf): "Attached files (pdf)"
attach_a_file: "Attach a file"
add_an_attachment: "Add an attachment"
add_this_space: "Add this space"
default_places: "Default maximum tickets"
default_places_is_required: "Default maximum tickets is required."

View File

@ -396,6 +396,5 @@ fr:
attached_files_(pdf): "Pièces jointes (pdf)"
attach_a_file: "Joindre un fichier"
add_an_attachment: "Ajouter une pièce jointe"
add_this_space: "Ajouter cet espace"
default_places: "Maximum de places par défaut"
default_places_is_required: "Le nombre de places maximum par défaut est requis."