Skip to content
Snippets Groups Projects
Unverified Commit f7299f68 authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

Merge branch 'master' of github.com:noesya/osuny

parents c3779cf3 0d7148fe
No related branches found
No related tags found
No related merge requests found
Showing
with 102 additions and 16 deletions
......@@ -41,6 +41,7 @@ gem 'has_scope', '~> 0.8.0'
# Front
gem 'jquery-rails'
gem 'angularjs-rails'
gem 'sassc-rails'
gem 'jbuilder'
gem 'kamifusen'#, path: '../kamifusen'
......
......@@ -81,6 +81,7 @@ GEM
zeitwerk (~> 2.3)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
angularjs-rails (1.8.0)
annotate (3.2.0)
activerecord (>= 3.2, < 8.0)
rake (>= 10.4, < 14.0)
......@@ -427,6 +428,7 @@ PLATFORMS
ruby
DEPENDENCIES
angularjs-rails
annotate
aws-sdk-s3
bootsnap (>= 1.4.4)
......
......@@ -5,6 +5,7 @@
//= require notyf/notyf.min
//= require simple_form_password_with_hints
//= require simple_form_bs5_file_input
//= require angular
//= require cropperjs/dist/cropper
//= require jquery-cropper/dist/jquery-cropper
//= require appstack/app
......
......@@ -10,6 +10,10 @@ class Admin::Communication::Website::BlocksController < Admin::Communication::We
end
end
def show
breadcrumb
end
def new
@block.about_type = params[:about_type]
@block.about_id = params[:about_id]
......@@ -24,7 +28,7 @@ class Admin::Communication::Website::BlocksController < Admin::Communication::We
@block.university = @website.university
@block.website = @website
if @block.save
redirect_to [:admin, @block.about], notice: t('admin.successfully_created_html', model: @block.to_s)
redirect_to [:edit, :admin, @block], notice: t('admin.successfully_created_html', model: @block.to_s)
else
render :new, status: :unprocessable_entity
end
......@@ -50,7 +54,11 @@ class Admin::Communication::Website::BlocksController < Admin::Communication::We
super
add_breadcrumb @block.about.model_name.human(count: 2), [:admin, @block.about.class]
add_breadcrumb @block.about, [:admin, @block.about]
add_breadcrumb t('communication.website.block.choose_template')
if @block.new_record?
add_breadcrumb t('communication.website.block.choose_template')
else
add_breadcrumb @block
end
end
......
......@@ -36,6 +36,11 @@ class Communication::Website::Block < ApplicationRecord
partners: 200
}
def data=(value)
value = JSON.parse value if value.is_a? String
super(value)
end
def to_s
"Bloc #{position}"
end
......
......@@ -15,14 +15,19 @@
<th width="20" class="ps-0">&nbsp;</th>
<th><%= Communication::Website::Block.human_attribute_name('name') %></th>
<th><%= Communication::Website::Block.human_attribute_name('template') %></th>
<th></th>
</tr>
</thead>
<tbody data-sortable data-sort-url="<%= reorder_admin_communication_website_blocks_path %>">
<% about.blocks.ordered.each do |block| %>
<tr data-id="<%= block.id %>">
<td><i class="fa fa-bars handle"></i></td>
<td><%= link_to block, edit_admin_communication_website_block_path(block) %></td>
<td><%= link_to block, admin_communication_website_block_path(block) %></td>
<td><%= block.template_i18n %></td>
<td class="text-end">
<%= edit_link block %>
<%= destroy_link block %>
</td>
</tr>
<% end %>
</tbody>
......
......@@ -3,5 +3,5 @@ blocks:
<% about.blocks.each do |block| %>
- template: <%= block.template %>
data:
<%= render "admin/communication/website/blocks/templates/#{block.template}/static", block: block %><% end %>
<%= render "admin/communication/website/blocks/templates/#{block.template}/static", block: block if block.data %><% end %>
<% end %>
<% content_for :title, @block %>
<%= simple_form_for [:admin, @block] do |f| %>
<%= render "admin/communication/website/blocks/templates/#{@block.template}/edit", f: f %>
<% content_for :action_bar_right do %>
<%= submit f %>
<%
@block.data = {} if @block.data.nil? || @block.data.blank?
@block.data['elements'] ||= []
%>
<div ng-app ng-init="data = <%= @block.data.is_a?(String) ? @block.data : @block.data.to_json %>">
<%= simple_form_for [:admin, @block] do |f| %>
<%= render "admin/communication/website/blocks/templates/#{@block.template}/edit", f: f %>
<textarea name="communication_website_block[data]" rows="20" cols="200" class="d-none">{{ data | json}}</textarea>
<% content_for :action_bar_right do %>
<%= submit f %>
<% end %>
<% end %>
<% end %>
</div>
<% content_for :title, @block %>
<%= render "admin/communication/website/blocks/templates/#{@block.template}/show" %>
<% content_for :action_bar_right do %>
<%= edit_link @block %>
<% end %>
<%= f.input :data %>
<a class="<%= button_classes('mb-2') %>" ng-click="data.elements.push({title: 'Role name', persons: []})">Add role</a>
<div class="card" ng-repeat="element in data.elements">
<div class="card-body">
<div class="row">
<div class="col-md-5">
<div class="row">
<div class="col-md-11">
<input class="form-control" type="text" ng-model="element.title">
</div>
<div class="col-md-1 text-end">
<a class="btn btn-sm btn-danger mt-1" ng-click="data.elements.splice(data.elements.indexOf(element))"><i class="fas fa-trash"></i></a>
</div>
</div>
</div>
<div class="offset-md-1 col-md-6">
<div class="row">
<div class="col-md-8">
<p>People</p>
</div>
<div class="col-md-4 text-end">
<a class="<%= button_classes %>" ng-click="element.persons.push({slug: ''})">Add person</a>
</div>
</div>
<div ng-repeat="person in element.persons" class="mb-2">
<div class="row">
<div class="col-md-11">
<select class="form-select select" ng-model="person.slug">
<% @website.university.people.each_with_index do |person, index| %>
<option value="<%= person.slug %>"><%= person %></option>
<% end %>
</select>
</div>
<div class="col-md-1 text-end">
<a class="btn btn-sm btn-danger mt-1" ng-click="element.persons.splice(element.persons.indexOf(person))"><i class="fas fa-trash"></i></a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<% @block.data['elements'].each do |element| %>
<h2><%= element['title'] %></h2>
<% element['persons'].each do |person| %>
<p><%= person['slug'] %></p>
<% end %>
<% end %>
- title: Leadership
<% if !block.data.nil? && !block.data.is_a?(String) && block.data.has_key?('elements') %>
<% block.data['elements'].each do |element| %>
- title: >
<%= element['title'] %>
persons:
- amah-edoh
- liliane-umubyeyi
<% element['persons'].each do |person| %>
- "<%= person['slug'] %>"
<% end %>
<% end %>
<% end %>
<%= f.input :data %>
......@@ -25,7 +25,7 @@ namespace :communication do
resources :authors, controller: 'website/authors', only: [:index, :show]
resources :posts, controller: 'website/posts'
resources :curations, path: 'posts/curations', as: :post_curations, controller: 'website/posts/curations', only: [:new, :create]
resources :blocks, controller: 'website/blocks', except: [:index, :show] do
resources :blocks, controller: 'website/blocks', except: :index do
collection do
post :reorder
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment