Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI Filters (Implementation) #1253

Closed
wants to merge 95 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
81d79cb
cp: First draft for Filters, mostly copied from Forms for the beginning
alex40724 Oct 24, 2018
b243563
cp: Second draft, more cleaned up
alex40724 Oct 24, 2018
60e3e00
cp: Ready for Pull Request
alex40724 Oct 24, 2018
d3da70f
cp: Wording
alex40724 Oct 24, 2018
8d3a133
cp: Changes for Filter Field
alex40724 Oct 24, 2018
c2e3a55
cp: fixed some rules
alex40724 Oct 24, 2018
fa9cf08
cp: very, very basic filter ideas
alex40724 Oct 24, 2018
ac62423
cp: Changes from comments and JF
alex40724 Oct 24, 2018
e65b82c
cp: Trifle
alex40724 Oct 24, 2018
679f9d4
cp: Trifle again
alex40724 Oct 24, 2018
12bb6c7
cp: Still basic Filter Service ideas
alex40724 Oct 24, 2018
7b964cb
cp: Still basic Filter Service ideas 2
alex40724 Oct 24, 2018
6980bc1
cp: sketched processing
alex40724 Oct 24, 2018
1a84294
cp: First try to get data from request
alex40724 Oct 24, 2018
8e2ba4d
cp: merged filter changes from 5_4_cat_filters2 up to b411ae1 (withou…
alex40724 Oct 24, 2018
c22dc23
cp: merged filter changes from 5_4_cat_filters2 up to 8820e63
alex40724 Oct 24, 2018
98257d6
cp: merged filter changes from 5_4_cat_filters2 up to 9198d37
alex40724 Oct 24, 2018
3e97cce
cp: Basic functionality of showing Labels and Values in the Filter Ba…
alex40724 Oct 24, 2018
3d624d0
cp: First ideas for Add-Button and Remove-Glyph
alex40724 Oct 24, 2018
c6a76e2
cp: merged changes from 5_4_cat_filters2 of c872761
alex40724 Oct 24, 2018
e7dfba2
updated style json, composer autoloader and delos.css
alex40724 Oct 24, 2018
ee51ef2
use correct glyphs
alex40724 Oct 24, 2018
f88d8ce
accordion behavior for popovers in mobile view
alex40724 Oct 24, 2018
92e52c7
force expanded if activated and non-mobile
alex40724 Oct 25, 2018
64303ce
fixed form submission
alex40724 Oct 25, 2018
1f94a72
add select
alex40724 Oct 25, 2018
8f683c9
add select
alex40724 Oct 25, 2018
7e862be
fixed value being displayed in proxy
alex40724 Oct 25, 2018
a4b6374
fixed session handling for values
alex40724 Oct 25, 2018
5fc92ae
Behavior for removing and adding Inputs to the Filter
tfamula Oct 25, 2018
f3ff476
Merge branch '5_4_ks_filter2' of https://github.com/leifos-gmbh/ILIAS…
tfamula Oct 25, 2018
d35d21d
fixed getting data from service
alex40724 Oct 25, 2018
3cd3e77
Merge branch '5_4_ks_filter2' of https://github.com/leifos-gmbh/ILIAS…
alex40724 Oct 25, 2018
e1775cd
Removed double inheritance
tfamula Oct 25, 2018
14dd515
Merge branch '5_4_ks_filter2' of https://github.com/leifos-gmbh/ILIAS…
tfamula Oct 25, 2018
da06741
restored tabindex
alex40724 Oct 25, 2018
bd7365c
Accessibility for Input Fields and improvement for adding Input Fields
tfamula Oct 25, 2018
fa50bc8
show/hide filter behaviour
alex40724 Oct 25, 2018
61dceeb
Merge branch '5_4_ks_filter2' of https://github.com/leifos-gmbh/ILIAS…
alex40724 Oct 25, 2018
bd24bf3
polished ui service
alex40724 Oct 25, 2018
ea195e5
updated readme
alex40724 Oct 25, 2018
51e956c
polished renderer
alex40724 Oct 25, 2018
c2ea99d
some less cleanup, more needed, and variables
alex40724 Oct 25, 2018
1c71b4e
some less, js polishing, needs more
alex40724 Oct 25, 2018
424b0da
fixed some type hints
alex40724 Oct 26, 2018
c25355e
moved action generating to request adapter
alex40724 Oct 26, 2018
b51fc9e
added missing mem vars
alex40724 Oct 26, 2018
4e953e7
added missing mem vars
alex40724 Oct 26, 2018
ce0a9dd
added missing purpose/rules
alex40724 Oct 26, 2018
5a8c21b
Less variables + cleanup
tfamula Oct 26, 2018
c1c688d
get rid of DIC dependency
alex40724 Oct 26, 2018
c2c1678
Started Filter tests
tfamula Oct 26, 2018
cba40b2
fixed duplicate class name
alex40724 Oct 29, 2018
3b18241
cherry picked 06871bf4bb5ad38473ef2be5f61c90db3f09ba1a from loading a…
alex40724 Oct 29, 2018
a7bc273
fixed more tests
alex40724 Oct 29, 2018
d3dcb30
Update Services/Init/classes/class.ilInitialisation.php
klees Oct 29, 2018
b1d21f0
Update Services/UI/classes/class.ilUIFilterService.php
klees Oct 29, 2018
bf9c1b6
Update Services/UI/classes/class.ilUIFilterService.php
klees Oct 29, 2018
26e9643
Added some more tests
tfamula Oct 29, 2018
617fcec
fixed tests; removed vardump
alex40724 Oct 29, 2018
863fc27
pass ui as dependency
alex40724 Oct 29, 2018
0123164
Render tests
tfamula Oct 29, 2018
8790363
Merge branch '5_4_ks_filter2' of https://github.com/leifos-gmbh/ILIAS…
tfamula Oct 29, 2018
403bc91
Fix for render tests
tfamula Oct 29, 2018
085b554
POST tests
tfamula Oct 30, 2018
35c32b8
first tests using get
alex40724 Oct 29, 2018
e950746
Second tests using GET
tfamula Nov 2, 2018
239e5f6
GET not working actually
tfamula Nov 6, 2018
a1c2a37
GET with javascript
tfamula Nov 6, 2018
b8a6df1
GET with javascript 2
tfamula Nov 7, 2018
e025a72
Bugfix for filter request
tfamula Nov 8, 2018
759c9e5
JS cleanup
tfamula Nov 8, 2018
4083023
Removed double inheritance for Radio Input
tfamula Nov 8, 2018
104dcc1
Temporary template change to prevent conflict with cherry-pick
tfamula Nov 16, 2018
9bc415e
Interface, implementation and examples for disabled inputs
tfamula Nov 9, 2018
cd279da
Prevent request for disabled inputs
tfamula Nov 14, 2018
5cda8e8
Disabled state for (dependant) group and section
tfamula Nov 15, 2018
1a61065
Restoring template changes
tfamula Nov 16, 2018
efcd6f5
Filter deactivation with real disabled inputs
tfamula Nov 16, 2018
9896a1c
Cherry pick from disabled input PR
tfamula Nov 20, 2018
eb2bdc0
Removed comment
tfamula Nov 22, 2018
500848f
Added documentation and fixed tests
tfamula Nov 22, 2018
232d3f9
Changes for disabled Tag Input
tfamula Nov 21, 2018
6dcaf7a
Solved violation with immutability
tfamula Nov 27, 2018
b3596c6
Restructuring JS Code
tfamula Dec 11, 2018
c266690
Fix to prevent losing filter status when clicking on collapse without…
tfamula Dec 11, 2018
ed7bb0b
Removed too much code
tfamula Dec 11, 2018
18a6a88
OnUpdate for all inputs
tfamula Dec 21, 2018
dfa2477
Filter improvements, part 1
tfamula Feb 1, 2019
8ef5fd0
Filter improvements, part 2
tfamula Feb 13, 2019
4f4d361
Small fixes
tfamula Feb 13, 2019
f91745b
Changes for expand/collapse Filter with Ajax
tfamula Mar 15, 2019
77b6ba3
Bulky Button instead of Glyph in Filter Bar
tfamula Mar 25, 2019
3a89a35
Slight border to separate Filter Bar from Inputs
tfamula Mar 25, 2019
c0a07e0
Design fixes for very long Filter Inputs
tfamula Mar 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Services/Init/classes/class.ilInitialisation.php
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,10 @@ protected static function initUIFramework(\ILIAS\DI\Container $c) {
return new ILIAS\UI\Implementation\Component\Input\Field\Factory($c["ui.signal_generator"]);
};
$c["ui.factory.input.container"] = function($c) {
return new ILIAS\UI\Implementation\Component\Input\Container\Factory();
return new ILIAS\UI\Implementation\Component\Input\Container\Factory(
$c["ui.signal_generator"],
$c["ui.factory.input.field"]
);
};
$c["ui.factory.panel.listing"] = function($c) {
return new ILIAS\UI\Implementation\Component\Panel\Listing\Factory();
Expand All @@ -1579,6 +1582,12 @@ protected static function initUIFramework(\ILIAS\DI\Container $c) {
, $c["ui.template_factory"]
, $c["lng"]
, $c["ui.javascript_binding"]
),
new ILIAS\UI\Implementation\Component\Input\Field\FieldRendererFactory
($c["ui.factory"]
, $c["ui.template_factory"]
, $c["lng"]
, $c["ui.javascript_binding"]
)
)
)
Expand Down
2 changes: 1 addition & 1 deletion Services/Style/System/data/data.json

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions Services/UI/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# UI Filter Service

The filter service wraps the KS element of Standard Input Filters. It's main purpose is to manage the state of the filter and it's inputs in the user session.

The basics methods are `$DIC->uiService()->filter()->standard()` to get a filter instance and `$DIC->uiService()->filter()->getData($filter)` to retrieve the data from the filter.

This service is most probably a temporary solution until session and similar dependencies are handled differently by the UI framework.

```

class fooGUI {

function showListAndFilter() {

//Step 0: Declare dependencies
global $DIC;
$ui = $DIC->ui()->factory();
$renderer = $DIC->ui()->renderer();

//Step 1: Define some input fields to plug into the filter.
$title_input = $ui->input()->field()->text("Title");
$select = $ui->input()->field()->select("Selection", ["one" => "One", "two" => "Two", "three" => "Three"]);
$with_def = $ui->input()->field()->text("With Default")->withValue("Def.Value");
$init_hide = $ui->input()->field()->text("Hidden initially");

//Step 2: Define the filter and attach the inputs.
$action = $DIC->ctrl()->getLinkTargetByClass("ilsystemstyledocumentationgui", "entries", "", true);
$filter = $DIC->uiService()->filter()->standard("filter_ID", $action, [
"title" => $title_input,
"select" => $select,
"with_def" => $with_def,
"init_hide" => $init_hide,
],
[true, true, true, false], true, true);

//Step 3: Get filter data
$filter_data = $DIC->uiService()->filter()->getData($filter);

//Step 4: Render the filter
return $renderer->render($filter)."Filter Data: ".print_r($filter_data, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't render the values that the user entered imo. They are added from POST in getData, but the updated $filter is never retrieved. Thus $filter here only contains the values that where initially set to the fields.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bildschirmfoto 2018-10-29 um 10 39 30

What do you mean "won't" render? Did you try the example in the KS? You enter some data in the "Title" field, hit "Apply" (Do not use "Enter" key, this needs fixing) and the data is retrieved and displayed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just now noticed, that you effectively add the POST-data to the input twice, once in handleApply, once in getData. This was irritating but should work.

}

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for the example in the readme.



```
98 changes: 98 additions & 0 deletions Services/UI/classes/class.ilUIFilterRequestAdapter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php

/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */

use \ILIAS\UI\Component\Input\Container\Filter;
use \Psr\Http\Message\ServerRequestInterface;

/**
* Request adapter for filter
*
* @author [email protected]
* @ingroup ServicesUI
*/
class ilUIFilterRequestAdapter
{
const CMD_PARAMETER = "cmdFilter";
const RENDER_INPUT_BASE = "__filter_status_";

/**
* @var ServerRequestInterface
*/
protected $request;

/**
* query params
* @var array
*/
protected $params;

/**
* post data
* @var array|null
*/
protected $post;

/**
* Constructor
*/
public function __construct(ServerRequestInterface $request)
{
$this->request = $request;
$this->params = $this->request->getQueryParams();
$this->post = $this->request->getParsedBody();
}

/**
* Get filter command
* @return string
*/
public function getFilterCmd(): string
{
if (isset($this->params[self::CMD_PARAMETER]))
{
return (string) $this->params[self::CMD_PARAMETER];
}
return "";
}

/**
* Has an input field been rendered in current post request?
*
* @param $input_id
* @return bool
*/
public function isInputRendered($input_id): bool
{
if (isset($this->params[self::RENDER_INPUT_BASE . $input_id]) &&
$this->params[self::RENDER_INPUT_BASE . $input_id] === "1")
{
return true;
}
return false;
}

/**
* Get filter with request data
*
* @param Filter\Standard $filter
* @return Filter\Standard
*/
public function getFilterWithRequest(Filter\Standard $filter): Filter\Standard
{
return $filter->withRequest($this->request);
}

/**
* Get action for filter command
*
* @param string $base_action
* @param string $filter_cmd
* @return string
*/
public function getAction(string $base_action, string $filter_cmd): string
{
return $base_action."&".self::CMD_PARAMETER."=".$filter_cmd;
}

}
Loading