FEATURE: conditionally publish views in module, fix confirm dialog for forms

This commit is contained in:
Michal Kváček
2017-08-25 11:40:34 +02:00
parent 8bae8a43f9
commit 6468c8f49c
4 changed files with 37 additions and 22 deletions
@@ -13,6 +13,7 @@ abstract class ServiceProvider extends LaravelServiceProvider
protected $defer = false; protected $defer = false;
protected $alias = false; protected $alias = false;
protected $path = false; protected $path = false;
protected $publishViews = true;
abstract protected function setModuleAlias(); abstract protected function setModuleAlias();
@@ -59,7 +60,7 @@ abstract class ServiceProvider extends LaravelServiceProvider
return $path . '/modules/' . $this->alias; return $path . '/modules/' . $this->alias;
}, \Config::get('view.paths')), [$sourcePath]), $this->alias); }, \Config::get('view.paths')), [$sourcePath]), $this->alias);
if (is_dir($sourcePath)) { if (is_dir($sourcePath) && $this->publishViews) {
$this->publishes([$sourcePath => $viewPath], 'module-views'); $this->publishes([$sourcePath => $viewPath], 'module-views');
} }
} }
+23 -15
View File
@@ -82,7 +82,6 @@ $ (function () {
}); });
}); });
function setSameHeights($container) { function setSameHeights($container) {
$container = $container || $ ('.sameheight-container'); $container = $container || $ ('.sameheight-container');
@@ -197,7 +196,7 @@ $ (function () {
setThemeSettings (); setThemeSettings ();
setSameHeights(); setSameHeights ();
/************************************************ /************************************************
* Events * Events
@@ -380,9 +379,18 @@ $ (document).ready (function () {
var confirmTitle = $ (this).data ('title'); var confirmTitle = $ (this).data ('title');
var confirmMessage = $ (this).data ('message'); var confirmMessage = $ (this).data ('message');
var tag = $ (this).prop ('tagName');
if (tag === 'A') {
var href = $ (this).attr ('href'); var href = $ (this).attr ('href');
$ ('#confirm-button').attr ('href', href); $ ('#confirm-button').attr ('href', href);
} else if (tag === 'BUTTON') {
var form = $(this).closest('form');
$ ('#confirm-button').click (function () {
form.submit();
})
}
if (confirmTitle) if (confirmTitle)
titleElement.text (confirmTitle); titleElement.text (confirmTitle);
@@ -392,7 +400,7 @@ $ (document).ready (function () {
$ ('#confirm-modal').modal ('show'); $ ('#confirm-modal').modal ('show');
$('.main-wrapper').addClass('blur'); $ ('.main-wrapper').addClass ('blur');
e.preventDefault (); e.preventDefault ();
}); });
@@ -400,7 +408,7 @@ $ (document).ready (function () {
$ ('#confirm-modal').on ('hidden.bs.modal', function () { $ ('#confirm-modal').on ('hidden.bs.modal', function () {
$ ('#confirmation-title').text (previousTitle); $ ('#confirmation-title').text (previousTitle);
$ ('#confirmation-message').text (previousMessage); $ ('#confirmation-message').text (previousMessage);
$('.main-wrapper').removeClass('blur'); $ ('.main-wrapper').removeClass ('blur');
}); });
$ ('#lockUrl').change (function () { $ ('#lockUrl').change (function () {
@@ -433,24 +441,24 @@ $ (document).ready (function () {
$ ("#" + tabCard.prop ('id') + "-tab").addClass ('tab-with-error'); $ ("#" + tabCard.prop ('id') + "-tab").addClass ('tab-with-error');
}); });
$('#removeTitlePhoto').click(function () { $ ('#removeTitlePhoto').click (function () {
$('#titlePhotoContainer').remove(); $ ('#titlePhotoContainer').remove ();
// $('existingTitlePhoto').val(null); // $('existingTitlePhoto').val(null);
}); });
$('form').areYouSure(); $ ('form').areYouSure ();
}); });
$('.checkbox').change(function() { $ ('.checkbox').change (function () {
var e = $(this); var e = $ (this);
var checked = e.is(':checked'); var checked = e.is (':checked');
var id = e.data('id'); var id = e.data ('id');
$('.child-'+id).prop('checked', checked); $ ('.child-' + id).prop ('checked', checked);
// check also parent // check also parent
if (e.hasClass('child-checkbox') && checked){ if (e.hasClass ('child-checkbox') && checked) {
var parent = e.data('parent'); var parent = e.data ('parent');
$('#checkbox-parent-'+parent).prop('checked', true); $ ('#checkbox-parent-' + parent).prop ('checked', true);
} }
}); });
@@ -24,13 +24,14 @@
display: flex; display: flex;
flex-flow: column nowrap; flex-flow: column nowrap;
}
&.striped { .striped {
& > div { & > div, & tr {
border-bottom: 1px solid $item-list-color-border; border-bottom: 1px solid $item-list-color-border;
} }
& > div:nth-child(2n + 1) { & > div:nth-child(2n + 1), & tr:nth-child(2n + 1) {
background-color: lighten($color-divider, 12%); background-color: lighten($color-divider, 12%);
@include media-down(sm) { @include media-down(sm) {
@@ -42,7 +43,6 @@
border-bottom: none; border-bottom: none;
} }
} }
}
/* ******************************************* /* *******************************************
* Item general styles * Item general styles
@@ -0,0 +1,6 @@
<form action="{{$action}}" method="post" class="d-inline">
{!! csrf_field() !!}
{!! method_field('DELETE') !!}
<button class="btn btn-danger confirm btn-sm rounded"><i class="fa fa-trash"></i></button>
</form>