parent
60e33407e1
commit
d1c3e432db
@ -1,9 +0,0 @@ |
||||
{# Customization of the grid is located here: grid_theme.html.twig #} |
||||
|
||||
{#{{ grid_search(grid) }}#} |
||||
{#{{ grid(grid) }}#} |
||||
|
||||
{#{{ grid(grid, 'APYDataGridBundle::blocks_js.jquery.html.twig') }}#} |
||||
|
||||
{{ grid(grid, '@ChamiloCore/Resource/grid_theme_ajax.html.twig') }} |
||||
|
@ -1,289 +0,0 @@ |
||||
{% extends 'APYDataGridBundle::blocks.html.twig' %} |
||||
|
||||
{# This file is loaded from config/services.yaml and then used in all grids. #} |
||||
|
||||
{# See block documentation here: #} |
||||
{# https://github.com/APY/APYDataGridBundle/blob/master/Resources/doc/template/overriding_internal_blocks.md #} |
||||
|
||||
{% block grid_column_massaction_cell %} |
||||
<input type="checkbox" class="action" value="1" name="{{ grid.hash }}[{{ column.id }}][{{ row.primaryFieldValue }}]"/> |
||||
{% endblock grid_column_massaction_cell %} |
||||
|
||||
{% block grid_actions %} |
||||
{# <a class="btn btn-secondary" href="#" onclick="return {{ grid.hash }}_markVisible(true);">#} |
||||
{# {{ 'Select visible'|trans }}#} |
||||
{# </a>#} |
||||
{# <a class="btn btn-secondary" href="#" onclick="return {{ grid.hash }}_markVisible(false);">#} |
||||
{# {{ 'Deselect visible'|trans }}#} |
||||
{# </a>#} |
||||
{# <a class="btn btn-secondary" href="#" onclick="return {{ grid.hash }}_markAll(true);">#} |
||||
{# {{ 'Select all'|trans }}#} |
||||
{# </a>#} |
||||
{# <a class="btn btn-secondary" href="#" onclick="return {{ grid.hash }}_markAll(false);">#} |
||||
{# {{ 'Deselect all'|trans }}#} |
||||
{# </a>#} |
||||
{# <span class="mass-actions-selected" id="{{ grid.hash }}_mass_action_selected"></span>#} |
||||
{% apply spaceless %} |
||||
<div style="float:right; display:none" class="grid_massactions"> |
||||
{{ 'Action'|trans }} |
||||
<input type="hidden" id="{{ grid.hash }}_mass_action_all" |
||||
name="{{ grid.hash }}[{{ constant('APY\\DataGridBundle\\Grid\\Grid::REQUEST_QUERY_MASS_ACTION_ALL_KEYS_SELECTED') }}]" |
||||
value="0"/> |
||||
<select name="{{ grid.hash }}[{{ constant('APY\\DataGridBundle\\Grid\\Grid::REQUEST_QUERY_MASS_ACTION') }}]" |
||||
class="show-tick"> |
||||
<option value="-1"></option> |
||||
{% for key, massAction in grid.massActions %} |
||||
<option value="{{ key }}">{{ massAction.title|trans }}</option> |
||||
{% endfor %} |
||||
</select> |
||||
<input id="mass_action_button" class="btn btn-secondary" type="submit" value="{{ 'Submit'|trans }}"/> |
||||
</div> |
||||
{% endapply %} |
||||
|
||||
{% endblock grid_actions %} |
||||
|
||||
{# Bootstrap changes #} |
||||
{% block grid_column_actions_cell %} |
||||
{% set actions = column.getActionsToRender(row) %} |
||||
<div class="btn-group btn-group-sm"> |
||||
{% for action in actions %} |
||||
{% if action.attributes.form_delete is defined and action.attributes.form_delete %} |
||||
<div class="btn-group"> |
||||
<form method="post" action="{{ url(action.route, column.routeParameters(row, action), false) }}"> |
||||
<input type="hidden" name="_method" value="DELETE" /> |
||||
<button type="submit" class="btn btn-danger"> |
||||
{{ action.title|trans }} |
||||
</button> |
||||
</form> |
||||
</div> |
||||
{% else %} |
||||
{% if action.attributes.iframe is defined and action.attributes.iframe %} |
||||
<a |
||||
data-fancybox data-type="iframe" |
||||
href="javascript:;" |
||||
data-src="{{ url(action.route, column.routeParameters(row, action), false) }}" |
||||
{% for name, value in action.attributes %} {{ name }}="{{ value }}" {% endfor %} |
||||
> |
||||
{% if action.attributes.icon is defined and action.attributes.icon %} |
||||
<i class="fas {{ action.attributes.icon }} "></i> |
||||
{% else %} |
||||
{{ action.title|trans }} |
||||
{% endif %} |
||||
</a> |
||||
{% else %} |
||||
<a |
||||
href="{{ url(action.route, column.routeParameters(row, action), false) }}" |
||||
target="{{ action.target }}" |
||||
{% if action.confirm %} onclick="return confirm('{{ action.confirmMessage }}')"{% endif %} |
||||
{% for name, value in action.attributes %} {{ name }}="{{ value }}" {% endfor %} |
||||
|
||||
{% if action.attributes.data_hidden is defined and action.attributes.data_hidden %} |
||||
style="display: none" |
||||
{% endif %} |
||||
> |
||||
{% if action.attributes.icon is defined and action.attributes.icon %} |
||||
<i class="fas {{ action.attributes.icon }} "></i> |
||||
{% else %} |
||||
{{ action.title|trans }} |
||||
{% endif %} |
||||
</a> |
||||
{% endif %} |
||||
{% endif %} |
||||
{% endfor %} |
||||
</div> |
||||
{% endblock grid_column_actions_cell %} |
||||
|
||||
{% block grid_scripts %} |
||||
{{ parent() }} |
||||
<script> |
||||
function clickRow(firstRow) { |
||||
var anchor = firstRow.find('a'); |
||||
var url = anchor.attr('href'); |
||||
|
||||
url = url.replace('/view_resource?', '/info?'); |
||||
url = url.replace('/view?', '/info?'); |
||||
url = url.replace('/list?', '/info?'); |
||||
if (url) { |
||||
$.ajax({ |
||||
type: "get", |
||||
url: url, |
||||
contentType: "html", |
||||
beforeSend: function () { |
||||
}, |
||||
success: function (response) { |
||||
$('#resources').attr('class', 'col-lg-8'); |
||||
$('#info_bar').attr('class', 'col-lg-4'); |
||||
$('#info_bar').html(response); |
||||
}, |
||||
}); |
||||
} |
||||
} |
||||
|
||||
|
||||
$(function () { |
||||
$('tbody').on('click', 'tr', function (event) { |
||||
if ($(this).is('tr:first')) { |
||||
return; |
||||
} |
||||
|
||||
if (event.ctrlKey === false) { |
||||
$(this).siblings().find('input:checkbox').prop('checked', false); |
||||
$(this).siblings('tr:visible').removeClass('table-active'); |
||||
} |
||||
|
||||
var checkbox = $(this).find('input'); |
||||
checkbox.prop('checked', !checkbox.prop('checked')); |
||||
$(this).toggleClass('table-active'); |
||||
|
||||
var rows = $('tbody tr.table-active').length; |
||||
if (rows == 0) { |
||||
$('.mass-actions').hide(); |
||||
} else { |
||||
if ($('#info_bar').is(':visible')) { |
||||
clickRow($(this)); |
||||
} |
||||
$('.mass-actions').show(); |
||||
} |
||||
}); |
||||
|
||||
$('.resource_info_row').on('click', function (event) { |
||||
console.log('resource_info_row'); |
||||
var row = $(this).parent().parent().parent(); |
||||
$('#info_bar').show(); |
||||
clickRow(row); |
||||
event.preventDefault(); |
||||
}); |
||||
|
||||
$('.resource_info').on('click', function (event) { |
||||
var firstRow = $('tbody tr.table-active:first '); |
||||
var rowCount = firstRow.length; |
||||
if (rowCount) { |
||||
$('#info_bar').show(); |
||||
clickRow(firstRow); |
||||
} |
||||
event.preventDefault(); |
||||
}); |
||||
|
||||
}); |
||||
</script> |
||||
|
||||
{% endblock %} |
||||
|
||||
{% block grid %} |
||||
<div class="box box-primary"> |
||||
<div class="box-body table-responsive no-padding"> |
||||
{% if grid.totalCount > 0 or grid.isFiltered or grid.noDataMessage is same as(false) %} |
||||
<form id="{{ grid.hash }}" action="{{ grid.routeUrl }}" method="post"> |
||||
|
||||
<div class="grid_header"> |
||||
{% if grid.massActions|length > 0 %} |
||||
{{ grid_actions(grid) }} |
||||
{% endif %} |
||||
</div> |
||||
|
||||
<div class="grid_body"> |
||||
<table class="table table-hover table-sm"> |
||||
{% if grid.isTitleSectionVisible %} |
||||
{{ grid_titles(grid) }} |
||||
{% endif %} |
||||
{% if grid.isFilterSectionVisible %} |
||||
{{ grid_filters(grid) }} |
||||
{% endif %} |
||||
{{ grid_rows(grid) }} |
||||
</table> |
||||
</div> |
||||
<div class="grid_footer"> |
||||
{% if grid.isPagerSectionVisible %} |
||||
{{ grid_pager(grid) }} |
||||
{% endif %} |
||||
{% if grid.exports|length > 0 %} |
||||
{{ grid_exports(grid) }} |
||||
{% endif %} |
||||
{% if grid.tweaks|length > 0 %} |
||||
{{ grid_tweaks(grid) }} |
||||
{% endif %} |
||||
</div> |
||||
{% if withjs %} |
||||
{{ grid_scripts(grid) }} |
||||
{% endif %} |
||||
</form> |
||||
{% else %} |
||||
{{ grid_no_data(grid) }} |
||||
{% endif %} |
||||
</div> |
||||
</div> |
||||
{% endblock grid %} |
||||
|
||||
{% block grid_search %} |
||||
{% if grid.isFilterSectionVisible %} |
||||
<div class="col-md-12"> |
||||
{% set searchContent %} |
||||
<form id="{{ grid.hash }}_search" action="{{ grid.routeUrl }}" method="post"> |
||||
{% for column in grid.columns %} |
||||
{% if column.isFilterable and column.type not in ['actions', 'massaction'] %} |
||||
{% set columnTitle = grid.prefixTitle ~ column.title %} |
||||
<div class="{{ cycle(['odd', 'even'], loop.index) }}"> |
||||
<label>{{ columnTitle|trans }}</label> |
||||
{{ grid_filter(column, grid, false)|raw }} |
||||
</div> |
||||
{% endif %} |
||||
{% endfor %} |
||||
<div class="grid-search-action"> |
||||
<input type="submit" class="btn btn-secondary grid-search-submit" value="{{ 'Search'|trans }}"/> |
||||
<input type="button" class="btn btn-secondary grid-search-reset" value="{{ 'Reset'|trans }}" |
||||
onclick="return {{ grid.hash }}_reset();"/> |
||||
</div> |
||||
</form> |
||||
{% endset %} |
||||
<div class="card"> |
||||
<div class="card-header"> {{ 'Filters' | trans }} </div> |
||||
<div class="card-body"> |
||||
{{ searchContent }} |
||||
</div> |
||||
</div> |
||||
</div> |
||||
{% endif %} |
||||
{% endblock grid_search %} |
||||
|
||||
{% block grid_column_filter_type_input %} |
||||
{% set btwOperator = constant('APY\\DataGridBundle\\Grid\\Column\\Column::OPERATOR_BTW') %} |
||||
{% set btweOperator = constant('APY\\DataGridBundle\\Grid\\Column\\Column::OPERATOR_BTWE') %} |
||||
{% set isNullOperator = constant('APY\\DataGridBundle\\Grid\\Column\\Column::OPERATOR_ISNULL') %} |
||||
{% set isNotNullOperator = constant('APY\\DataGridBundle\\Grid\\Column\\Column::OPERATOR_ISNOTNULL') %} |
||||
{% set op = column.data.operator is defined ? column.data.operator : column.defaultOperator %} |
||||
{% set from = column.data.from is defined ? column.data.from : null %} |
||||
{% set to = column.data.to is defined ? column.data.to : null %} |
||||
<div class="form-group row"> |
||||
<label for="staticEmail" class="col-sm-2 col-form-label"> |
||||
{{ grid_column_operator(column, grid, op, submitOnChange) }} |
||||
<input type="{{ column.inputType }}" value="{{ to }}" class="grid-filter-input-query-to" name="{{ grid.hash }}[{{ column.id }}][to]" id="{{ grid.hash }}__{{ column.id }}__query__to" {% if submitOnChange is same as (true) %}onkeypress="return {{ grid.hash }}_submitForm(event, this.form);"{% endif%} {{ ( op == btwOperator or op == btweOperator ) ? '': 'style="display: none;" disabled="disabled"' }} /> |
||||
</label> |
||||
<div class="col-sm-10"> |
||||
<input type="{{ column.inputType }}" value="{{ from }}" class="form-control grid-filter-input-query-from" name="{{ grid.hash }}[{{ column.id }}][from]" id="{{ grid.hash }}__{{ column.id }}__query__from" {% if submitOnChange is same as (true) %}onkeypress="return {{ grid.hash }}_submitForm(event, this.form);"{% endif%} {{ ( op == isNullOperator or op == isNotNullOperator ) ? 'style="display: none;" disabled="disabled"' : '' }} /> |
||||
</div> |
||||
</div> |
||||
{% endblock grid_column_filter_type_input %} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{# ---------------------------------------------------- grid_pager_selectpage -------------------------------------------------- #} |
||||
{#{% block grid_pager_selectpage %}#} |
||||
{# {{ 'Page'|trans }}#} |
||||
{# {% spaceless %}#} |
||||
{# <input type="button" class="btn btn-secondary prev" {% if grid.page <= 0 %}disabled="disabled"{% endif %} value="<" onclick="return {{ grid.hash }}_previousPage();"/>#} |
||||
{# <input type="text" class="form-control current" value="{{ grid.page + 1 }}" size="2" onkeypress="return {{ grid.hash }}_enterPage(event, parseInt(this.value)-1);"/>#} |
||||
{# <input type="button" value=">" class="btn btn-secondary next" {% if grid.page >= grid.pageCount-1 %}disabled="disabled"{% endif %} onclick="return {{ grid.hash }}_nextPage();"/> {{ 'of %count%'|trans({ '%count%' : grid.pageCount }) }}#} |
||||
{# {% endspaceless %}#} |
||||
{#{% endblock grid_pager_selectpage %}#} |
||||
{# ---------------------------------------------------- grid_pager_results_perpage -------------------------------------------------- #} |
||||
{#{% block grid_pager_results_perpage %}#} |
||||
{# {{ ', Display'|trans }}#} |
||||
{# <select onchange="return {{ grid.hash }}_resultsPerPage(this.value);">#} |
||||
{# {% for key, value in grid.limits %}#} |
||||
{# <option value="{{ key }}"{% if (key == grid.limit) %} selected="selected"{% endif %}>{{ value }}</option>#} |
||||
{# {% endfor %}#} |
||||
{# </select> {{ 'Items per page'|trans }}#} |
||||
{#{% endblock grid_pager_results_perpage %}#} |
||||
|
@ -1,89 +0,0 @@ |
||||
{% extends '@ChamiloCore/Resource/grid_theme.html.twig' %} |
||||
|
||||
{% block grid_scripts_goto %} |
||||
function {{ grid.hash }}_goto(url, data, type) |
||||
{ |
||||
type = type || 'GET'; |
||||
data = data || []; |
||||
|
||||
$.ajax({ |
||||
url: url, |
||||
data: data, |
||||
type: type |
||||
}).done(function( msg ) { |
||||
var content = $(msg); |
||||
var grid = content.find('#{{ grid.hash }}'); |
||||
$('#{{ grid.hash }}').replaceWith(grid); |
||||
}); |
||||
return false |
||||
} |
||||
{% endblock grid_scripts_goto %} |
||||
|
||||
{% block grid_scripts_submit_form %} |
||||
function {{ grid.hash }}_submitForm(event, form) |
||||
{ |
||||
if (event.type != 'keypress' || event.which == 13) { |
||||
var data = ''; |
||||
$('.grid-filter-operator select, .grid-filter-input-query-from, .grid-filter-input-query-to, .grid-filter-select-query-from, .grid-filter-select-query-to', form).each(function () { |
||||
if ($(this).is(':disabled') == false) { |
||||
var name = $(this).attr('name'); |
||||
var value = $(this).val(); |
||||
if (value != null) { |
||||
if ($(this).attr('multiple') == 'multiple') { |
||||
for(var i= 0; i < value.length; i++) |
||||
{ |
||||
data += '&' + name + '=' + value[i]; |
||||
} |
||||
} else { |
||||
data += '&' + name + '=' + value; |
||||
} |
||||
} else { |
||||
data += '&' + name + '='; |
||||
} |
||||
} |
||||
}); |
||||
{{ grid.hash }}_goto('{{ grid.routeUrl }}', data.substring(1), 'POST'); |
||||
|
||||
return false; |
||||
} |
||||
} |
||||
{% endblock grid_scripts_submit_form %} |
||||
|
||||
{% block grid_scripts_ajax %} |
||||
$(function () { |
||||
// Order and pagerfanta links |
||||
$('.pagination li.disabled a', '#{{ grid.hash }}').click(function (e) { |
||||
return false; |
||||
}); |
||||
|
||||
// Order and pagerfanta links |
||||
$('a.order, nav a, a.searchOnClick, .pagination li:not(.disabled) a', '#{{ grid.hash }}').click(function () { |
||||
{{ grid.hash }}_goto(this.href); |
||||
|
||||
return false; |
||||
}); |
||||
|
||||
// Reset link |
||||
$('#{{ grid.hash }} a.grid-reset').click(function () { |
||||
{{ grid.hash }}_reset(); |
||||
|
||||
return false; |
||||
}); |
||||
|
||||
// Mass actions submit |
||||
$('#{{ grid.hash }} input.submit-massaction').click(function () { |
||||
var selector = $('#{{ grid.hash }} .grid_massactions select'); |
||||
|
||||
{{ grid.hash }}_goto('{{ grid.routeUrl }}', selector.attr('name') + '=' + selector.val(), 'POST'); |
||||
|
||||
return false; |
||||
}); |
||||
|
||||
// Grid_search submit (load only one time) |
||||
$('#{{ grid.hash }}_search').one('submit', function (event) { |
||||
{{ grid.hash }}_submitForm(event, this); |
||||
|
||||
return false; |
||||
}); |
||||
}); |
||||
{% endblock grid_scripts_ajax %} |
Loading…
Reference in new issue