mirror of
https://github.com/Karaka-Management/oms-Navigation.git
synced 2026-01-11 16:18:42 +00:00
update workflow
This commit is contained in:
parent
cef919692e
commit
83a287f8c4
95
.github/workflows/main.yml
vendored
95
.github/workflows/main.yml
vendored
|
|
@ -131,6 +131,96 @@ jobs:
|
|||
env:
|
||||
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
|
||||
run: "bash <(curl -s https://codecov.io/bash) -f tests/coverage.xml"
|
||||
static-tests:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, 'NO_CI')"
|
||||
strategy:
|
||||
fail-fast: false
|
||||
max-parallel: 3
|
||||
matrix:
|
||||
php-versions: ['8.0']
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
fetch-depth: 1
|
||||
submodules: recursive
|
||||
token: ${{ secrets.GITHUB }}
|
||||
- name: Checkout Build Repository
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
fetch-depth: 1
|
||||
ref: develop
|
||||
repository: Karaka/Build
|
||||
path: Build
|
||||
- name: Setup PHP, with composer and extensions
|
||||
uses: shivammathur/setup-php@master
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
extensions: mbstring, gd, zip, dom, mysql, pgsql, sqlite, imap, bcmath, redis, memcached
|
||||
ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1
|
||||
- name: Get Composer Cache Directory
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: ${{ runner.os }}-composer-
|
||||
- name: Setup Composer
|
||||
run: composer install
|
||||
- name: phpstan
|
||||
run: vendor/bin/phpstan analyse -a phpOMS/Autoloader.php --no-progress -l 9 -c Build/Config/phpstan.neon ./
|
||||
codestyle-tests:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, 'NO_CI')"
|
||||
strategy:
|
||||
fail-fast: false
|
||||
max-parallel: 3
|
||||
matrix:
|
||||
php-versions: ['8.0']
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
fetch-depth: 1
|
||||
submodules: recursive
|
||||
token: ${{ secrets.GITHUB }}
|
||||
- name: Checkout Build Repository
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
fetch-depth: 1
|
||||
ref: develop
|
||||
repository: Karaka/Build
|
||||
path: Build
|
||||
- name: Setup PHP, with composer and extensions
|
||||
uses: shivammathur/setup-php@master
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
extensions: mbstring, gd, zip, dom, mysql, pgsql, sqlite, imap, bcmath, redis, memcached
|
||||
ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1
|
||||
- name: Get Composer Cache Directory
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: ${{ runner.os }}-composer-
|
||||
- name: Setup Composer
|
||||
run: composer install
|
||||
- name: phpcs
|
||||
run: vendor/bin/phpcs ./ --standard="Build/Config/phpcs.xml" -s --report=full
|
||||
- name: Install NPM
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '14'
|
||||
cache: 'npm'
|
||||
- run: npm install
|
||||
- name: eslint
|
||||
run: npx eslint ./ -c Build/Config/.eslintrc.json
|
||||
custom:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, 'NO_CI')"
|
||||
|
|
@ -165,6 +255,11 @@ jobs:
|
|||
run: |
|
||||
if [[ $(find ./ -name "*tpl.php" | xargs grep -E '=\"[\#\$\%\^\&\*\(\)\\/\ ]*\"') -ne "" ]]; then exit 1; fi
|
||||
if [[ $(find ./ -name "*tpl.php" | xargs grep -P '(\<img)((?!.*?alt=).)*(>)') -ne "" ]]; then exit 1; fi
|
||||
if [[ $(find ./ -name "*tpl.php" | xargs grep -P '(<input)((?!.*?type=).)*(>)') -ne "" ]]; then exit 1; fi
|
||||
if [[ $(find ./ -name "*tpl.php" | xargs grep -P '(<input|<select|<textarea)((?!.*?name=).)*(>)') -ne "" ]]; then exit 1; fi
|
||||
if [[ $(find ./ -name "*tpl.php" | xargs grep -P '(style=)') -ne "" ]]; then exit 1; fi
|
||||
if [[ $(find ./ -name "*tpl.php" | xargs grep -P '(value|title|alt|aria\-label)(=\")((?!\<\?).)*(>)') -ne "" ]]; then exit 1; fi
|
||||
if [[ $(find ./ -name "*tpl.php" | xargs grep -P '(\<td\>|\<th\>|\<caption\>|\<label.*?(\"|l)\>)) -ne "" ]]; then exit 1; fi
|
||||
- name: Js strict
|
||||
run: if [[ $(grep -r -L "\"use strict\";" --include=*.js ./) -ne "" ]]; then exit 1; fi
|
||||
- name: Js inspection
|
||||
|
|
|
|||
126
Controller.js
126
Controller.js
|
|
@ -1,126 +0,0 @@
|
|||
import { Autoloader } from '../../jsOMS/Autoloader.js';
|
||||
import { Application } from '../../Web/Backend/js/backend.js';
|
||||
import { Navigation } from './Models/Navigation.js';
|
||||
|
||||
Autoloader.defineNamespace('jsOMS.Modules');
|
||||
|
||||
/**
|
||||
* Navigation controller.
|
||||
*
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @since 1.0.0
|
||||
*/
|
||||
jsOMS.Modules.Navigation = class {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
constructor() {
|
||||
this.navigation = {};
|
||||
/** global: jsOMS */
|
||||
/** global: localStorage */
|
||||
this.rawNavData = JSON.parse(window.localStorage.getItem(Navigation.MODULE_NAME));
|
||||
this.rawNavData = this.rawNavData !== null ? this.rawNavData : {};
|
||||
};
|
||||
|
||||
/**
|
||||
* Bind navigation
|
||||
*
|
||||
* @param {string} id Navigation to bind (optional)
|
||||
*
|
||||
* @return {void}
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
bind (id) {
|
||||
const e = typeof id === 'undefined' ? document.getElementsByClassName('nav') : [document.getElementById(id)];
|
||||
const length = e.length;
|
||||
|
||||
for (let i = 0; i < length; ++i) {
|
||||
if (e[i] === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.bindElement(e[i]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Bind navigation element
|
||||
*
|
||||
* @param {Element} e Element to bind
|
||||
*
|
||||
* @return {void}
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
bindElement (e) {
|
||||
const extend = e.querySelectorAll('li label');
|
||||
const self = this;
|
||||
|
||||
this.navigation[e.id] = new Navigation(this.rawNavData[e.id]);
|
||||
|
||||
// On load
|
||||
const open = this.navigation[e.id].getOpen();
|
||||
let ele = null;
|
||||
|
||||
for (let key in open) {
|
||||
if (open.hasOwnProperty(key) && (ele = document.getElementById(key)) !== null) {
|
||||
ele.checked = open[key];
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.navigation[e.id].isVisible()) {
|
||||
let width = window.innerWidth
|
||||
|| document.documentElement.clientWidth
|
||||
|| document.body.clientWidth;
|
||||
|
||||
/**
|
||||
* @todo Navigation sidebar width
|
||||
* The sidebar navigation is not working properly if the content is too wide then the side nav becomes smaller (resize window for testing)
|
||||
*/
|
||||
e.nextElementSibling.checked = width < 800;
|
||||
}
|
||||
|
||||
e.scrollTop = this.navigation[e.id].getScrollPosition().y;
|
||||
e.scrollLeft = this.navigation[e.id].getScrollPosition().x;
|
||||
|
||||
// Bind minimize/maximize
|
||||
jsOMS.addEventListenerToAll(extend, 'click', function () {
|
||||
let box = document.getElementById(this.getAttribute('for'));
|
||||
|
||||
if (!box.checked) {
|
||||
self.navigation[e.id].setOpen(box.id);
|
||||
} else {
|
||||
self.navigation[e.id].setClose(box.id);
|
||||
}
|
||||
|
||||
localStorage.setItem(Navigation.MODULE_NAME, JSON.stringify(self.navigation));
|
||||
});
|
||||
|
||||
// Bind show/hide
|
||||
e.addEventListener('change', function () {
|
||||
self.navigation[e.id].setVisible(this.checked);
|
||||
localStorage.setItem(Navigation.MODULE_NAME, JSON.stringify(self.navigation));
|
||||
});
|
||||
|
||||
// Bind scroll
|
||||
e.addEventListener('scroll', function () {
|
||||
self.navigation[e.id].setScrollPosition(this.scrollLeft, this.scrollTop);
|
||||
localStorage.setItem(Navigation.MODULE_NAME, JSON.stringify(self.navigation));
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Module id
|
||||
*
|
||||
* @var {string}
|
||||
* @since 1.0.0
|
||||
*/
|
||||
Navigation.MODULE_NAME = '1000500001';
|
||||
|
||||
window.omsApp.moduleManager.get('Navigation').bind('nav-side-outer');
|
||||
|
|
@ -1,131 +0,0 @@
|
|||
export class Navigation {
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param {Object} data Initialization (optional)
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
constructor (data)
|
||||
{
|
||||
if (typeof data === 'undefined') {
|
||||
this.scrollPosition = {x: 0, y: 0};
|
||||
this.activeLinks = {};
|
||||
this.visible = true;
|
||||
this.openCategories = {};
|
||||
} else {
|
||||
this.scrollPosition = typeof data.scrollPosition === 'undefined' ? {x : 0, y : 0} : data.scrollPosition;
|
||||
this.activeLinks = typeof data.activeLinks === 'undefined' ? {} : data.activeLinks;
|
||||
this.visible = typeof data.visible === 'undefined' ? true : data.visible;
|
||||
this.openCategories = typeof data.openCategories === 'undefined' ? {} : data.openCategories;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Set scroll position
|
||||
*
|
||||
* @param {int} x Horizontal position
|
||||
* @param {int} y Vertical position
|
||||
*
|
||||
* @return {void}
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
setScrollPosition (x, y)
|
||||
{
|
||||
this.scrollPosition.x = x;
|
||||
this.scrollPosition.y = y;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get scroll position
|
||||
*
|
||||
* @return {Object}
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
getScrollPosition ()
|
||||
{
|
||||
return this.scrollPosition;
|
||||
};
|
||||
|
||||
/**
|
||||
* Open navigation category
|
||||
*
|
||||
* @param {string} id Category id
|
||||
*
|
||||
* @return {void}
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
setOpen (id)
|
||||
{
|
||||
this.openCategories[id] = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Close navigation category
|
||||
*
|
||||
* @param {string} id Category id
|
||||
*
|
||||
* @return {void}
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
setClose (id)
|
||||
{
|
||||
delete this.openCategories[id];
|
||||
};
|
||||
|
||||
/**
|
||||
* Get open navigation elements
|
||||
*
|
||||
* @return {Object}
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
getOpen ()
|
||||
{
|
||||
return this.openCategories;
|
||||
};
|
||||
|
||||
active (id)
|
||||
{
|
||||
this.allInactive();
|
||||
};
|
||||
|
||||
allInactive ()
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
inactive (id)
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* Set navigation visibility
|
||||
*
|
||||
* @param {bool} visible Visibility
|
||||
*
|
||||
* @return {bool}
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
setVisible (visible)
|
||||
{
|
||||
this.visible = visible;
|
||||
};
|
||||
|
||||
/**
|
||||
* Is navigation visible
|
||||
*
|
||||
* @return {bool}
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
isVisible ()
|
||||
{
|
||||
return this.visible;
|
||||
};
|
||||
};
|
||||
|
|
@ -19,12 +19,12 @@ use \Modules\Navigation\Models\NavigationType;
|
|||
* @var \Modules\Navigation\Views\NavigationView $this
|
||||
*/
|
||||
if (isset($this->nav[NavigationType::SIDE])) : ?>
|
||||
<div id="nav-side-outer">
|
||||
<div id="nav-side-outer" class="oms-ui-state">
|
||||
<ul id="nav-side-inner" class="nav" role="navigation">
|
||||
<?php
|
||||
$uriPath = $this->request->uri->getPath();
|
||||
foreach ($this->nav[NavigationType::SIDE][LinkType::CATEGORY] as $key => $parent) : ?>
|
||||
<li><input id="nav-<?= $this->printHtml($parent['nav_name']); ?>" type="checkbox">
|
||||
<li><input class="oms-ui-state" id="nav-<?= $this->printHtml($parent['nav_name']); ?>" type="checkbox">
|
||||
<ul>
|
||||
<li><label for="nav-<?= $this->printHtml($parent['nav_name']); ?>">
|
||||
<?php if (isset($parent['nav_icon'])) : ?>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user