Added views for QOR admin

This commit is contained in:
Nedim
2023-09-07 13:04:34 +02:00
parent 40c6366608
commit f02e5e49cb
180 changed files with 18556 additions and 2 deletions

View File

@@ -0,0 +1,13 @@
$(function() {
'use strict';
$(document).on('click.qor.alert', '[data-dismiss="alert"]', function() {
$(this)
.closest('.qor-alert')
.removeClass('qor-alert__active');
});
setTimeout(function() {
$('.qor-alert[data-dismissible="true"]').removeClass('qor-alert__active');
}, 5000);
});

View File

@@ -0,0 +1,36 @@
$(function () {
'use strict';
var modal = (
'<div class="qor-dialog qor-dialog--global-search" tabindex="-1" role="dialog" aria-hidden="true">' +
'<div class="qor-dialog-content">' +
'<form action=[[actionUrl]]>' +
'<div class="mdl-textfield mdl-js-textfield" id="global-search-textfield">' +
'<input class="mdl-textfield__input ignore-dirtyform" name="keyword" id="globalSearch" value="" type="text" placeholder="" />' +
'<label class="mdl-textfield__label" for="globalSearch">[[placeholder]]</label>' +
'</div>' +
'</form>' +
'</div>' +
'</div>'
);
$(document).on('click', '.qor-dialog--global-search', function(e){
e.stopPropagation();
if (!$(e.target).parents('.qor-dialog-content').length && !$(e.target).is('.qor-dialog-content')){
$('.qor-dialog--global-search').remove();
}
});
$(document).on('click', '.qor-global-search--show', function(e){
e.preventDefault();
var data = $(this).data();
var modalHTML = window.Mustache.render(modal, data);
$('body').append(modalHTML);
window.componentHandler.upgradeElement(document.getElementById('global-search-textfield'));
$('#globalSearch').focus();
});
});

View File

@@ -0,0 +1,80 @@
$(function() {
'use strict';
let menuDatas = [],
storageName = 'qoradmin_menu_status',
lastMenuStatus = localStorage.getItem(storageName);
if (lastMenuStatus && lastMenuStatus.length) {
menuDatas = lastMenuStatus.split(',');
}
$('.qor-menu-container')
.on('click', '> ul > li > a', function() {
let $this = $(this),
$li = $this.parent(),
$ul = $this.next('ul'),
menuName = $li.attr('qor-icon-name');
if (!$ul.length) {
return;
}
if ($ul.hasClass('in')) {
menuDatas.push(menuName);
$li.removeClass('is-expanded');
$ul
.one('transitionend', function() {
$ul.removeClass('collapsing in');
})
.addClass('collapsing')
.height(0);
} else {
menuDatas = _.without(menuDatas, menuName);
$li.addClass('is-expanded');
$ul
.one('transitionend', function() {
$ul.removeClass('collapsing');
})
.addClass('collapsing in')
.height($ul.prop('scrollHeight'));
}
localStorage.setItem(storageName, menuDatas);
})
.find('> ul > li > a')
.each(function() {
let $this = $(this),
$li = $this.parent(),
$ul = $this.next('ul'),
menuName = $li.attr('qor-icon-name');
if (!$ul.length) {
return;
}
$ul.addClass('collapse');
$li.addClass('has-menu');
if (menuDatas.indexOf(menuName) != -1) {
$ul.height(0);
} else {
$li.addClass('is-expanded');
$ul.addClass('in').height($ul.prop('scrollHeight'));
}
});
let $pageHeader = $('.qor-page > .qor-page__header'),
$pageBody = $('.qor-page > .qor-page__body'),
triggerHeight = $pageHeader.find('.qor-page-subnav__header').length ? 96 : 48;
if ($pageHeader.length) {
if ($pageHeader.height() > triggerHeight) {
$pageBody.css('padding-top', $pageHeader.height());
}
$('.qor-page').addClass('has-header');
$('header.mdl-layout__header').addClass('has-action');
}
});

View File

@@ -0,0 +1,5 @@
$(function () {
$('.qor-mobile--show-actions').on('click', function () {
$('.qor-page__header').toggleClass('actions-show');
});
});

View File

@@ -0,0 +1,162 @@
$(function() {
"use strict";
let $body = $("body"),
Slideout,
BottomSheets,
CLASS_IS_SELECTED = "is-selected",
isSlideoutOpened = function() {
return $body.hasClass("qor-slideout-open");
},
isBottomsheetsOpened = function() {
return $body.hasClass("qor-bottomsheets-open");
};
$body.qorBottomSheets();
$body.qorSlideout();
Slideout = $body.data("qor.slideout");
BottomSheets = $body.data("qor.bottomsheets");
function toggleSelectedCss(ele) {
$("[data-url]").removeClass(CLASS_IS_SELECTED);
ele && ele.length && ele.addClass(CLASS_IS_SELECTED);
}
function collectSelectID() {
let $checked = $(".qor-js-table tbody").find(
".mdl-checkbox__input:checked"
),
IDs = [];
if (!$checked.length) {
return false;
}
$checked.each(function() {
IDs.push(
$(this)
.closest("tr")
.data("primary-key")
);
});
return IDs;
}
$(document).on("click.qor.openUrl", "[data-url]", function(e) {
let $this = $(this),
$target = $(e.target),
isNewButton = $this.hasClass("qor-button--new"),
isEditButton = $this.hasClass("qor-button--edit"),
isInTable =
($this.is(".qor-table tr[data-url]") ||
$this.closest(".qor-js-table").length) &&
!$this.closest(".qor-slideout").length, // if table is in slideout, will open bottom sheet
openData = $this.data(),
actionData,
openType = openData.openType,
hasSlideoutTheme = $this.parents(".qor-theme-slideout").length,
isInSlideout = $this.closest(".qor-slideout").length,
isActionButton =
$this.hasClass("qor-action-button") ||
$this.hasClass("qor-action--button");
e.stopPropagation();
// if clicking item's menu actions
if (
$this.data("ajax-form") ||
$target.closest(".qor-table--bulking").length ||
$target.closest(".qor-button--actions").length ||
(!$target.data("url") && $target.is("a")) ||
(isInTable && isBottomsheetsOpened())
) {
return;
}
if (openType == "window") {
window.location.href = openData.url;
return;
}
if (openType == "new_window") {
window.open(openData.url, "_blank");
return;
}
if (isActionButton) {
actionData = collectSelectID();
if (actionData) {
openData = $.extend({}, openData, {
actionData: actionData
});
}
}
openData.$target = $target;
if (!openData.method || openData.method.toUpperCase() == "GET") {
// Open in BottmSheet: is action button, open type is bottom-sheet
// is action button but opentype == slideout, should open in slideout\
// open type is No.1 priority
if (
(openType == "bottomsheet" || isActionButton) &&
openType != "slideout"
) {
// if is bulk action and no item selected
if (
isActionButton &&
!actionData &&
$this.closest('[data-toggle="qor.action.bulk"]').length &&
!isInSlideout
) {
window.QOR.qorConfirm(openData.errorNoItem);
return false;
}
BottomSheets.open(openData);
return false;
}
// Slideout or New Page: table items, new button, edit button
if (
openType == "slideout" ||
isInTable ||
(isNewButton && !isBottomsheetsOpened()) ||
isEditButton
) {
if (openType == "slideout" || hasSlideoutTheme) {
if ($this.hasClass(CLASS_IS_SELECTED)) {
Slideout.hide();
toggleSelectedCss();
return false;
} else {
Slideout.open(openData);
toggleSelectedCss($this);
return false;
}
} else {
window.location.href = openData.url;
return false;
}
}
// Open in BottmSheet: slideout is opened or openType is Bottom Sheet
if (isSlideoutOpened() || (isNewButton && isBottomsheetsOpened())) {
BottomSheets.open(openData);
return false;
}
// Other clicks
if (hasSlideoutTheme) {
Slideout.open(openData);
return false;
} else {
BottomSheets.open(openData);
return false;
}
}
});
});

View File

@@ -0,0 +1,33 @@
$(function () {
'use strict';
var location = window.location;
$('.qor-search').each(function () {
var $this = $(this);
var $input = $this.find('.qor-search__input');
var $clear = $this.find('.qor-search__clear');
var isSearched = !!$input.val();
var emptySearch = function () {
var search = location.search.replace(new RegExp($input.attr('name') + '\\=?\\w*'), '');
if (search == '?'){
location.href = location.href.split('?')[0];
} else {
location.search = location.search.replace(new RegExp($input.attr('name') + '\\=?\\w*'), '');
}
};
$this.closest('.qor-page__header').addClass('has-search');
$('header.mdl-layout__header').addClass('has-search');
$clear.on('click', function () {
if ($input.val() || isSearched) {
emptySearch();
} else {
$this.removeClass('is-dirty');
}
});
});
});