Commit 64651b47 authored by pvincent's avatar pvincent

afficher formulaire avec meta_options

parent 51a38d3a
......@@ -9,13 +9,13 @@ Les services actuellement couverts sont :
* Jitsi Meet
* Etherpad (en développement)
TODO
----
Développement En cours (pvincent)
---------------------------------
* [X] Config populate META-options
* [ ] afficher le formulaire en fonction des META-options
* [X] imbriqué les instances dans les config modules
* [ ] stocker les données dans une table -> INSTANCE-options
* [X] afficher le formulaire en fonction des META-options
* [X] imbriquer les instances dans les config modules
* [ ] stocker les données dans une table -> INSTANCE-options
* [ ] factoriser le controlleur de modules
* [ ] sur le modèle de INSTANCE-options, faire DOMAIN-options et USER-options
......
This diff is collapsed.
......@@ -31,7 +31,10 @@ class InstancesController < ApplicationController
respond_to do |format|
if @instance.save
format.html { redirect_to [@config_module, @instance], notice: 'Une instance a été créée avec succès.' }
format.html do
redirect_to [@config_module, @instance],
notice: 'Une instance a été créée avec succès.'
end
format.json { render :show, status: :created, location: @instance }
else
format.html { render :new }
......@@ -45,6 +48,11 @@ class InstancesController < ApplicationController
def update
respond_to do |format|
if @instance.update(instance_params)
@instance_options = params['meta']
p @instance_options
format.html { redirect_to [@config_module, @instance], notice: 'Instance was successfully updated.' }
format.json { render :show, status: :ok, location: @instance }
else
......
# frozen_string_literal: true
# Copyright (c) 2017 Jean-Noël Rouchon <jnoel@mithril.re>
#
# This file is part of Zourit.
......@@ -16,6 +18,11 @@
# along with Zourit. If not, see <http://www.gnu.org/licenses/>.
class ConfigModule < ActiveRecord::Base
has_many :domain_infos
has_many :tickets
has_many :domain_infos
has_many :tickets
has_many :meta_options
def instance_options
meta_options.select { |mo| mo.field == 'instance' }
end
end
# frozen_string_literal: true
class InstanceOption < ActiveRecord::Base
belongs_to :Instance
belongs_to :MetaOption
end
......@@ -9,19 +9,6 @@
</h1>
</div>
<div class="panel-body">
<!-- pvincent pour jnoel, module zourit commenté ! -->
<!-- A SUPPRIMER quand c'est validé -->
<%# <div class="col-sm-6 col-md-3 col-lg-1">
<a href="/configs/0">
<div class="caption tuile_mini">
<span><i class="fa fa-gear fa-4x hvr-grow-rotate"></i></span>
<p>Zourit</p>
</div>
</a>
</div> %>
<% @modules.each do |m| %>
<div class="col-sm-6 col-md-3 col-lg-1">
<a href="/config_modules/<%= m.id %>">
......
......@@ -24,17 +24,19 @@
<th>Active</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<% @instances.each do |instance| %>
<tr>
<td><%= instance.name %></td>
<td>
<%= link_to config_module_instance_path(@module, instance) do %>
<%= instance.name %>
<% end %>
</td>
<td><%= instance.description %></td>
<td><%= instance.active %></td>
<td><%= link_to 'Show', config_module_instance_path(@module, instance) %></td>
<td><%= link_to 'Edit', edit_config_module_instance_path(@module, instance) %></td>
<td><%= link_to 'Destroy', config_module_instance_path(@module, instance), method: :delete, data: { confirm: 'Êtes-vous sr(e) ?' } %></td>
</tr>
......
......@@ -12,25 +12,45 @@
</div>
<% end %>
<div class="field">
<%= f.label :name %><br>
<%= f.text_field :name, readonly: readonly %>
</div>
<div class="field">
<%= f.label :description %><br>
<%= f.text_area :description, readonly: readonly %>
</div>
<div class="field">
<%= f.label :active %><br>
<%= f.check_box :active, disabled: readonly %>
<div class="form-group">
<%= f.label :name %>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user fa-lg" aria-hidden="true"></i></span>
<%= f.text_field :name, readonly: readonly %>
</div>
</div>
<%= f.label :description %>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user fa-lg" aria-hidden="true"></i></span>
<%= f.text_area :description, readonly: readonly %>
</div>
</div>
<%= f.label :active %>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user fa-lg" aria-hidden="true"></i></span>
<%= f.check_box :active, readonly: readonly %>
</div>
</div>
<hr/>
<h4>Meta Options</h4>
<% @config_module.instance_options.each do |io| %>
<%= render partial: 'meta_option', object: io, readonly: readonly %>
<% end %>
</div>
<% unless readonly %>
<% unless readonly # EDIT vs SHOW%>
<div class="actions">
<%= f.submit %>
</div>
<% end%>
<% end %>
<% end %>
<% meta_name = "meta[#{meta_option.id}]" # ici, j'utilise le même name des formulaires avec meta[...]%>
<%= label_tag meta_option.description %>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user fa-lg" aria-hidden="true"></i></span>
<% case meta_option.field_type.downcase %>
<% when 'password' %>
<%= password_field_tag meta_name, '', placeholder: meta_option.placeholder %>
<% else %>
<%= text_field_tag meta_name, '', placeholder: meta_option.placeholder %>
<% end %>
</div>
</div>
......@@ -9,10 +9,17 @@
</div>
<div class="panel-body">
<%= render 'form' %>
<div class="row">
<%= link_to 'Show', config_module_instance_path(@config_module, @instance) %> |
<%= link_to 'Back', config_module_path(@config_module) %>
<div class="col-sm-6 col-md-6 text-left col-md-offset-3">
<h4 class="text-center"><%= t '.title'%></h4>
<%= render 'form' %>
<%= link_to 'Show', config_module_instance_path(@config_module, @instance) %> |
<%= link_to 'Back', config_module_path(@config_module) %>
</div>
</div>
</div>
</div>
......
......@@ -6,14 +6,20 @@
<%= "Visualisation de l'instance #{@config_module.name} : '#{@instance.name}'" %>
</h1>
</div>
<div class="panel-body">
<p id="notice"><%= notice %></p>
<%= render 'form', readonly: true %>
<div class="panel-body">
<div class="row">
<%= link_to 'Edit', edit_config_module_instance_path(@config_module, @instance) %> |
<%= link_to 'Back', config_module_path(@config_module) %>
<div class="col-sm-6 col-md-6 text-left col-md-offset-3">
<h4 class="text-center"><%= t '.title'%></h4>
<%= render 'form', readonly: true %>
<%= link_to 'Edit', edit_config_module_instance_path(@config_module, @instance) %> |
<%= link_to 'Back', config_module_path(@config_module) %>
</div>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
......@@ -3,66 +3,65 @@
<div class="container">
<div class="panel panel-warning shadow">
<div class="panel-heading clearfix">
<h1>
<%= I18n.t "terms.mypofile" %>
</h1>
<h1><%= I18n.t "terms.myprofile" %></h1>
</div>
<div class="panel-body">
<div class="row">
<div class="col-sm-6 col-md-6 text-left col-md-offset-3">
<h4 class="text-center"><%= I18n.t "terms.changeparamuser"%> </p></h4>
<div class="form-group">
<input type="hidden" class="form-control" id="userId" value="<%= @user.id %>">
<label for="motdepass"><%= I18n.t "terms.yourlastname"%> </label>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user fa-lg" aria-hidden="true"></i></span>
<input type="text" class="form-control" id="userLastName" placeholder="Nom" value="<%= @user.last_name %>">
</div>
<h4 class="text-center"><%= I18n.t "terms.changeparamuser"%> </p>
</h4>
<div class="form-group">
<input type="hidden" class="form-control" id="userId" value="<%= @user.id %>">
<label for="motdepass"><%= I18n.t "terms.yourlastname"%> </label>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user fa-lg" aria-hidden="true"></i></span>
<input type="text" class="form-control" id="userLastName" placeholder="Nom" value="<%= @user.last_name %>">
</div>
</div>
<div class="form-group">
<label for="motdepass"><%= I18n.t "terms.yourfirstname"%> </label>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user fa-lg" aria-hidden="true"></i></span>
<input type="text" class="form-control" id="userFirstName" placeholder="Prénom" value="<%= @user.first_name %>">
</div>
</div>
<div class="form-group">
<label for="motdepass"><%= I18n.t "terms.yourfirstname"%> </label>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user fa-lg" aria-hidden="true"></i></span>
<input type="text" class="form-control" id="userFirstName" placeholder="Prénom" value="<%= @user.first_name %>">
</div>
</div>
<div class="form-group">
<label for="motdepass"><%= I18n.t "terms.yournewpdw"%> </label>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock fa-lg" aria-hidden="true"></i></span>
<input type="password" class="form-control" id="userPassword" placeholder="Nouveau mot de passe" value="">
</div>
</div>
<div class="form-group">
<label for="motdepass"><%= I18n.t "terms.yournewpdw"%> </label>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock fa-lg" aria-hidden="true"></i></span>
<input type="password" class="form-control" id="userPassword" placeholder="Nouveau mot de passe" value="">
</div>
</div>
<div class="form-group">
<label for="motdepass"><%= I18n.t "terms.confirmpwd"%> </label>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock fa-lg" aria-hidden="true"></i></span>
<input type="password" class="form-control" id="userConfirmPassword" placeholder="Confirmation du nouveau mot de passe" value="">
</div>
</div>
<div class="form-group">
<label for="motdepass"><%= I18n.t "terms.confirmpwd"%> </label>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock fa-lg" aria-hidden="true"></i></span>
<input type="password" class="form-control" id="userConfirmPassword" placeholder="Confirmation du nouveau mot de passe" value="">
</div>
</div>
<div class="form-group">
<label for="motdepass"><%= I18n.t "terms.choosetheme"%> </label>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-pencil fa-lg" aria-hidden="true"></i></span>
<input type="text" class="form-control" id="userTheme" placeholder="Entrer un numéro de thème allant de 1 à 11" value="<%= @user.theme %>">
</div>
</div>
<div class="form-group">
<label for="motdepass"><%= I18n.t "terms.choosetheme"%> </label>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-pencil fa-lg" aria-hidden="true"></i></span>
<input type="text" class="form-control" id="userTheme" placeholder="Entrer un numéro de thème allant de 1 à 11" value="<%= @user.theme %>">
</div>
</div>
<button type="submit" class="btn btn-primary" id="userValidate">
<i></i>
<%= I18n.t "terms.validchange"%>
</button>
</div>
<!--
<button type="submit" class="btn btn-primary" id="userValidate">
<i></i>
<%= I18n.t "terms.validchange"%>
</button>
</div>
<!--
<div class="col-sm-6 col-md-6">
<h4 class="text-center">Statistiques d'utilisation</p></h4>
<br/>
......@@ -77,9 +76,9 @@
<span class="progress-completed">20/90Go</span>
</div>
</div>-->
</div>
</div>
</div>
</div>
</div>
</div>
......@@ -127,13 +127,13 @@ en:
admin: "Admin"
quota : "Quota"
verif: "Are you sure ?"
changeparamuser: "You can change your personnal settings in this page"
changeparamuser: "You can change any of your personal settings in this page"
yourlastname: "Your last name"
yourfirstname: "Your first name"
yournewpdw: "Your new password"
confirmpwd: "Confirm your new password"
paramde: "Settings of "
validchange: "Valid changes"
validchange: "Confirm changes"
#visio
visio: "Visioconferences"
......@@ -155,5 +155,17 @@ en:
addexternuser: "Add external user"
saisirmail: "You can entry one e-mail adress per line"
adduservisio: "Add users to videoconference"
#layout
myservices: "My services"
#profile
myprofile: "My profile"
choosetheme: "Choose your theme"
instances:
show:
title: Show one instance
edit:
title: Edit instance
......@@ -347,4 +347,4 @@ fr:
gereralias: "Gestion des alias"
#profile
mypofile: "Mon profil"
myprofile: "Mon profil"
# frozen_string_literal: true
class CreateInstanceOption < ActiveRecord::Migration
def change
create_table :instance_options do |t|
t.string :key, null: false
t.string :value, null: false
t.references :instance, index: true, foreign_key: true
t.references :meta_option, index: true, foreign_key: true
t.timestamps null: false
end
end
end
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20191022070423) do
ActiveRecord::Schema.define(version: 20191112103026) do
create_table "config_modules", force: :cascade do |t|
t.string "name"
......@@ -41,6 +41,18 @@ ActiveRecord::Schema.define(version: 20191022070423) do
add_index "domain_infos", ["config_module_id"], name: "index_domain_infos_on_config_module_id"
add_index "domain_infos", ["instance_id"], name: "index_domain_infos_on_instance_id"
create_table "instance_options", force: :cascade do |t|
t.string "key", null: false
t.string "value", null: false
t.integer "instance_id"
t.integer "meta_option_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "instance_options", ["instance_id"], name: "index_instance_options_on_instance_id"
add_index "instance_options", ["meta_option_id"], name: "index_instance_options_on_meta_option_id"
create_table "instances", force: :cascade do |t|
t.integer "config_module_id"
t.string "name"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment