Initial commit,修正
This commit is contained in:
+69
@@ -0,0 +1,69 @@
|
||||
$('i.glyphicon-refresh-animate').hide();
|
||||
function updateRoutes(r) {
|
||||
_opts.routes.avaliable = r.avaliable;
|
||||
_opts.routes.assigned = r.assigned;
|
||||
search('avaliable');
|
||||
search('assigned');
|
||||
}
|
||||
|
||||
$('#btn-new').click(function () {
|
||||
var $this = $(this);
|
||||
var route = $('#inp-route').val().trim();
|
||||
if (route != '') {
|
||||
$this.children('i.glyphicon-refresh-animate').show();
|
||||
$.post($this.attr('href'), {route: route}, function (r) {
|
||||
$('#inp-route').val('').focus();
|
||||
updateRoutes(r);
|
||||
}).always(function () {
|
||||
$this.children('i.glyphicon-refresh-animate').hide();
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.btn-assign').click(function () {
|
||||
var $this = $(this);
|
||||
var target = $this.data('target');
|
||||
var routes = $('select.list[data-target="' + target + '"]').val();
|
||||
|
||||
if (routes && routes.length) {
|
||||
$this.children('i.glyphicon-refresh-animate').show();
|
||||
$.post($this.attr('href'), {routes: routes}, function (r) {
|
||||
updateRoutes(r);
|
||||
}).always(function () {
|
||||
$this.children('i.glyphicon-refresh-animate').hide();
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#btn-refresh').click(function () {
|
||||
var $icon = $(this).children('span.glyphicon');
|
||||
$icon.addClass('glyphicon-refresh-animate');
|
||||
$.post($(this).attr('href'), function (r) {
|
||||
updateRoutes(r);
|
||||
}).always(function () {
|
||||
$icon.removeClass('glyphicon-refresh-animate');
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.search[data-target]').keyup(function () {
|
||||
search($(this).data('target'));
|
||||
});
|
||||
|
||||
function search(target) {
|
||||
var $list = $('select.list[data-target="' + target + '"]');
|
||||
$list.html('');
|
||||
var q = $('.search[data-target="' + target + '"]').val();
|
||||
$.each(_opts.routes[target], function () {
|
||||
var r = this;
|
||||
if (r.indexOf(q) >= 0) {
|
||||
$('<option>').text(r).val(r).appendTo($list);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// initial
|
||||
search('avaliable');
|
||||
search('assigned');
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\helpers\Json;
|
||||
use mdm\admin\AnimateAsset;
|
||||
use yii\web\YiiAsset;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $routes [] */
|
||||
|
||||
$this->title = Yii::t('rbac-admin', 'Routes');
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
|
||||
AnimateAsset::register($this);
|
||||
YiiAsset::register($this);
|
||||
$opts = Json::htmlEncode([
|
||||
'routes' => $routes
|
||||
]);
|
||||
$this->registerJs("var _opts = {$opts};");
|
||||
$this->registerJs($this->render('_script.js'));
|
||||
$animateIcon = ' <i class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></i>';
|
||||
?>
|
||||
<div class="wrapper wrapper-content">
|
||||
|
||||
<div class="ibox-content">
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
<div class="row">
|
||||
<div class="col-sm-11">
|
||||
<div class="input-group">
|
||||
<input id="inp-route" type="text" class="form-control"
|
||||
placeholder="<?= Yii::t('rbac-admin', 'New route(s)') ?>">
|
||||
<span class="input-group-btn">
|
||||
<?= Html::a(Yii::t('rbac-admin', 'Add') . $animateIcon, ['create'], [
|
||||
'class' => 'btn btn-success',
|
||||
'id' => 'btn-new'
|
||||
]) ?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p> </p>
|
||||
<div class="row">
|
||||
<div class="col-sm-5">
|
||||
<div class="input-group">
|
||||
<input class="form-control search" data-target="avaliable"
|
||||
placeholder="<?= Yii::t('rbac-admin', 'Search for avaliable') ?>">
|
||||
<span class="input-group-btn">
|
||||
<?= Html::a('<span class="glyphicon glyphicon-refresh"></span>', ['refresh'], [
|
||||
'class' => 'btn btn-default',
|
||||
'id' => 'btn-refresh'
|
||||
]) ?>
|
||||
</span>
|
||||
</div>
|
||||
<select multiple size="20" class="form-control list" data-target="avaliable"></select>
|
||||
</div>
|
||||
<div class="col-sm-1">
|
||||
<br><br>
|
||||
<?= Html::a('>>' . $animateIcon, ['assign'], [
|
||||
'class' => 'btn btn-success btn-assign',
|
||||
'data-target' => 'avaliable',
|
||||
'title' => Yii::t('rbac-admin', 'Assign')
|
||||
]) ?><br><br>
|
||||
<?= Html::a('<<' . $animateIcon, ['remove'], [
|
||||
'class' => 'btn btn-danger btn-assign',
|
||||
'data-target' => 'assigned',
|
||||
'title' => Yii::t('rbac-admin', 'Remove')
|
||||
]) ?>
|
||||
</div>
|
||||
<div class="col-sm-5">
|
||||
<input class="form-control search" data-target="assigned"
|
||||
placeholder="<?= Yii::t('rbac-admin', 'Search for assigned') ?>">
|
||||
<select multiple size="20" class="form-control list" data-target="assigned"></select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user