weeks
This commit is contained in:
parent
25f09a3515
commit
6684552ceb
|
|
@ -13,7 +13,9 @@ module Admin
|
|||
|
||||
# GET /admin/courses/1
|
||||
# GET /admin/courses/1.json
|
||||
def show; end
|
||||
def show
|
||||
@weeks = @course.weeks
|
||||
end
|
||||
|
||||
# GET /admin/courses/new
|
||||
def new
|
||||
|
|
@ -76,7 +78,7 @@ module Admin
|
|||
end
|
||||
|
||||
def collection
|
||||
@courses = Course.by_name
|
||||
@courses = Course.name_asc
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ module SidemenuHelper
|
|||
link_to(raw("#{icon_text}<span>#{I18n.t(text)}</span>"),
|
||||
link, class: "nav-link#{expand ? '' : ' collapsed'}",
|
||||
data: { toggle: 'collapse', target: "#collapse#{name}" },
|
||||
aria: { expanded: "#{expand}", controls: "collapse#{name}" })
|
||||
aria: { expanded: expand.to_s, controls: "collapse#{name}" })
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -61,13 +61,12 @@ module SidemenuHelper
|
|||
def nav_link_submenu(a_name, submenu, for_active)
|
||||
content_tag :li, class: 'nav-item' do
|
||||
expand = check_link_active(for_active)
|
||||
r = nav_link_to(a_name[0], a_name[1], '#', a_name[2], expand)
|
||||
r += content_tag(:div, inner_submenu(submenu),
|
||||
concat nav_link_to(a_name[0], a_name[1], '#', a_name[2], expand)
|
||||
concat content_tag(:div, inner_submenu(submenu),
|
||||
id: "collapse#{a_name[2]}",
|
||||
class: "collapse#{expand ? ' show' : ''}",
|
||||
aria: { labelledby: "heading#{a_name[2]}" },
|
||||
data: { parent: '#accordionSidebar' })
|
||||
r
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -78,12 +77,9 @@ module SidemenuHelper
|
|||
# -> 'String' - to add header to menu
|
||||
def inner_submenu(submenu)
|
||||
content_tag :div, class: 'bg-white py-2 collapse-inner rounded' do
|
||||
r = nil
|
||||
submenu.each do |sub|
|
||||
r += submenu_element(sub) unless r.nil?
|
||||
r = submenu_element(sub) if r.nil?
|
||||
concat submenu_element(sub)
|
||||
end
|
||||
r
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Helper for views
|
||||
module ViewsHelper
|
||||
def dropdown_link(name, menu_links)
|
||||
content_tag(:div, class: 'dropdown no-arrow') do
|
||||
concat link_for('#', name)
|
||||
end
|
||||
end
|
||||
|
||||
def link_for(href, text)
|
||||
|
||||
end
|
||||
|
||||
=begin
|
||||
<div class="dropdown no-arrow">
|
||||
<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fas fa-ellipsis-v fa-sm fa-fw text-gray-400"></i>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right shadow animated--fade-in" aria-labelledby="dropdownMenuLink">
|
||||
<div class="dropdown-header">Dropdown Header:</div>
|
||||
<a class="dropdown-item" href="#">Action</a>
|
||||
<a class="dropdown-item" href="#">Another action</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="#">Something else here</a>
|
||||
</div>
|
||||
</div>
|
||||
=end
|
||||
end
|
||||
|
|
@ -1,21 +1,25 @@
|
|||
<table class="table table-bordered">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<th>Nazwa</th>
|
||||
<th>Opis</th>
|
||||
<th class="fit">Akcje</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @courses.each do |course| %>
|
||||
<% if @courses.blank? %>
|
||||
<%= render partial: '/admin/shared/norecords' %>
|
||||
<% else %>
|
||||
<table class="table table-bordered">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<td><%= link_to course.name, [:admin, course] %></td>
|
||||
<td><%= course.description %></td>
|
||||
<td class="fit">
|
||||
<%= link_to raw('<i class="fa fa-pencil-alt"></i>'), edit_admin_course_path(course), { remote: true, class: 'btn btn-sm btn-info', title: t('edit') } %>
|
||||
<%= link_to raw('<i class="fa fa-times"></i>'), [:admin, course], { remote: true, class: 'btn btn-sm btn-danger', method: :delete, data:{ confirm: t('confirm_delete') }, title: t('delete')} %>
|
||||
</td>
|
||||
<th>Nazwa</th>
|
||||
<th>Opis</th>
|
||||
<th class="fit">Akcje</th>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @courses.each do |course| %>
|
||||
<tr>
|
||||
<td><%= link_to course.name, [:admin, course] %></td>
|
||||
<td><%= course.description %></td>
|
||||
<td class="fit">
|
||||
<%= link_to raw('<i class="fa fa-pencil-alt"></i>'), edit_admin_course_path(course), { remote: true, class: 'btn btn-sm btn-info', title: t('edit') } %>
|
||||
<%= link_to raw('<i class="fa fa-times"></i>'), [:admin, course], { remote: true, class: 'btn btn-sm btn-danger', method: :delete, data:{ confirm: t('confirm_delete') }, title: t('delete')} %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<h1 class="h3 mb-1 text-gray-800">Kurs: <strong><%= @course.name %></strong></h1>
|
||||
<p class="mb-4"><%= @course.description %></p>
|
||||
<!-- Weeks -->
|
||||
|
||||
<%= render partial: '/admin/weeks/partials/index' %>
|
||||
|
||||
<%= link_to 'Back', admin_courses_path %>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
<div class="alert alert-primary" role="alert">
|
||||
<h4 class="alert-heading"><i class="fas fa-info-circle"></i> Informacja</h4>
|
||||
<p>Nie znaleziono żadnych elementów do wyświetlenia.</p>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
$('#ajax_form').slideUp();
|
||||
$('#ajax_list').html("<%= escape_javascript(render('/admin/weeks/partials/weeks')) %>");
|
||||
|
|
@ -0,0 +1 @@
|
|||
$('#ajax_list').html("<%= escape_javascript(render('/admin/weeks/partials/weeks')) %>");
|
||||
|
|
@ -0,0 +1 @@
|
|||
<%= render '/admin/weeks/partials/edit' %>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
$("#ajax_form").html("<%= escape_javascript(render('admin/weeks/partials/edit')) %>");
|
||||
$("#ajax_form").slideDown();
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
<h1 class="h3 mb-1 text-gray-800">Kursy</h1>
|
||||
<p class="mb-4">Tutaj jakiś opis.</p>
|
||||
<p id="notice"><%= notice %></p>
|
||||
<%= render partial: '/admin/weeks/partials/index' %>
|
||||
|
|
@ -0,0 +1 @@
|
|||
json.array! @weeks, partial: '/admin/weeks/partials/admin_week', as: :week
|
||||
|
|
@ -0,0 +1 @@
|
|||
<%= render partial: '/admin/weeks/partials/form' %>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
$("#ajax_form").html("<%= escape_javascript(render('admin/weeks/partials/new')) %>");
|
||||
$("#ajax_form").slideDown();
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
json.extract! week, :id, :name, :description, :created_at, :updated_at
|
||||
json.url admin_week_url(week, format: :json)
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<div class="row">
|
||||
<div class="col">
|
||||
<!-- Basic Card Example -->
|
||||
<div class="card shadow mb-4 border-primary">
|
||||
<div class="card-header text-white bg-primary">
|
||||
<h6>Edycja Tygodnia</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<%= render '/admin/weeks/partials/form', week: @week %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<%= form_with(model: [:admin, week]) do |form| %>
|
||||
<% if week.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(week.errors.count, "error") %> prohibited this admin_week from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% week.errors.full_messages.each do |message| %>
|
||||
<li><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<%= form.label :name %>
|
||||
<%= form.text_field :name, class: 'form-control' %>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<%= form.label :description %>
|
||||
<%= form.text_area :description, class: 'form-control' %>
|
||||
</div>
|
||||
</div>
|
||||
<%= form.submit 'Zapisz', class: 'btn btn-primary' %>
|
||||
<% end %>
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<div class="row">
|
||||
<div class="col">
|
||||
<!-- Basic Card Example -->
|
||||
<div class="card shadow mb-4">
|
||||
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
|
||||
<h6 class="m-0 font-weight-bold text-primary">Lista tygodni</h6>
|
||||
<%= link_to raw('<i class="fa fa-plus"></i> Dodaj Nowy Tydzien'), new_admin_week_path, { remote: true, class: 'btn btn-sm btn-primary float-right' } %>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div id="ajax_form"></div>
|
||||
<div id="ajax_list">
|
||||
<%= render partial: '/admin/weeks/partials/weeks' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<div class="row">
|
||||
<div class="col">
|
||||
<!-- Basic Card Example -->
|
||||
<div class="card shadow mb-4 border-primary">
|
||||
<div class="card-header text-white bg-primary">
|
||||
<h6>Nowy Tydzien</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<%= render '/admin/weeks/partials/form', week: @week %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<% if @weeks.blank? %>
|
||||
<%= render partial: '/admin/shared/norecords' %>
|
||||
<% else %>
|
||||
<table class="table table-bordered">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<th>Nazwa</th>
|
||||
<th>Opis</th>
|
||||
<th class="fit">Akcje</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @weeks.each do |week| %>
|
||||
<tr>
|
||||
<td><%= link_to week.name, [:admin, week] %></td>
|
||||
<td><%= week.description %></td>
|
||||
<td class="fit">
|
||||
<%= link_to raw('<i class="fa fa-pencil-alt"></i>'), edit_admin_week_path(week), { remote: true, class: 'btn btn-sm btn-info', title: t('edit') } %>
|
||||
<%= link_to raw('<i class="fa fa-times"></i>'), [:admin, week], { remote: true, class: 'btn btn-sm btn-danger', method: :delete, data:{ confirm: t('confirm_delete') }, title: t('delete')} %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<h1 class="h3 mb-1 text-gray-800">week: <strong><%= @week.name %></strong></h1>
|
||||
<p class="mb-4"><%= @week.description %></p>
|
||||
<!-- Weeks -->
|
||||
|
||||
|
||||
<%= link_to 'Back', admin_weeks_path %>
|
||||
|
|
@ -0,0 +1 @@
|
|||
json.partial! "/admin/weeks/partials/admin_week", week: @week
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
$('#ajax_form').slideUp();
|
||||
$('#ajax_list').html("<%= escape_javascript(render('/admin/weeks/partials/weeks')) %>");
|
||||
|
|
@ -1,11 +1,10 @@
|
|||
Rails.application.routes.draw do
|
||||
namespace :admin do
|
||||
resources :courses
|
||||
end
|
||||
get 'tests/index'
|
||||
get 'tests/test'
|
||||
namespace :admin do
|
||||
resources :users
|
||||
resources :courses
|
||||
resources :weeks
|
||||
end
|
||||
devise_for :users
|
||||
get 'home/index'
|
||||
|
|
|
|||
Loading…
Reference in New Issue