Commit 57fa8ad3 authored by Michael Herold's avatar Michael Herold
Browse files

Adds gui for radio input and conditional visibility

parent fd4b9c7b
......@@ -22,7 +22,7 @@ use Symfony\Component\Yaml;
class Config implements \ArrayAccess
{
const DEFAULT_CONFIG = 'default/config.yaml';
const DEFAULT_CONFIG = __DIR__.'/../../default/config.yaml';
public static function load($file)
{
......
<?php
/*
* Copyright (C) 2015 Michael Herold <quabla@hemio.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace hemio\edentata\gui;
use hemio\html;
use hemio\html\Interface_\HtmlCode;
use hemio\form\Abstract_\FormElement;
/**
* Description of ConditionalVisibility
*
* @author Michael Herold <quabla@hemio.de>
*/
class ConditionalVisibility extends \hemio\form\Container
{
/**
*
* @var HtmlCode
*/
protected $hiding;
/**
*
* @var FormElement
*/
protected $condition;
/**
*
* @var bool
*/
protected $reverse;
public function __construct(HtmlCode $hiding, FormElement $condition,
$reverse = false)
{
$this->hiding = $hiding;
$this->condition = $condition;
$this->reverse = $reverse;
$this['div'] = new html\Div;
$this['div'][] = $hiding;
$this['style'] = new html\Style();
$this['style']->setAttribute('scoped', true);
}
public function __toString()
{
if (!$this['div']->getAttribute('id'))
$this['div']->setAttribute('id',
$this->condition->getHtmlId().'_hiding');
$cssSelector = $this->reverse ? 'not(:checked)' : 'checked';
$this['style'][] = new html\Str(
'#'.$this->condition->getHtmlId().':'.$cssSelector.
' ~ #'.$this['div']->getAttribute('id').' { display: none; }');
return parent::__toString();
}
}
<?php
/*
* Copyright (C) 2015 Michael Herold <quabla@hemio.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace hemio\edentata\gui;
use hemio\html;
use hemio\form;
/**
* Description of FieldRadio
*
* @author Michael Herold <quabla@hemio.de>
*/
class FieldRadioList extends form\Container
{
protected $name;
protected $template;
protected $title;
public function __construct($name, $title = null)
{
$this->name = $name;
$this->title = $title;
$this['controls'] = new form\Container();
$this['ul'] = new html\Ul;
$this['ul']->addCssClass('listbox');
$this['ul']->addCssClass('radio');
$this['style'] = new html\Style();
$this['style']->setAttribute('scoped', true);
$this->template = new form\template\FormPlainControl;
$this->template->setPostInitHook(function ($template) {
$id = $template->field->getHtmlId();
$template->getControl()->addCssClass('list');
$template->field->getInheritableAppendage('label')
->setAttribute('for', $id);
$this['style'][] = new html\Str(
'input:not(:checked)[id='.$id.'] ~ * *[for='.$id.'] { '.
'color: inherit; background-color: inherit; }'
);
});
}
public function addOption($value, $content = null)
{
if ($content === null)
$content = $value;
$title = $content;
if ($this->title !== null)
$title = $this->title;
$radio = new form\FieldRadio($this->name, $title, $value);
$radio->addInheritableAppendage(
FormPost::FORM_FIELD_TEMPLATE.'_RADIO', $this->template
);
$this['controls'][] = $radio;
$li = new html\Li;
$li->addCssClass('listbox_link');
$label = new html\Label;
$label[] = new html\Str($content);
$label->addCssClass('listbox_content');
$radio->addInheritableAppendage('label', $label);
$li[] = $label;
$this['ul']->addChild($li);
return $radio;
}
public function getValueUser()
{
return $this['controls'][0]->getValueUser();
}
}
......@@ -45,10 +45,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
@import "gui/_switch.scss";
@import "gui/_textarea.scss";
@import "gui/_checkbox.scss";
@import "gui/_radio.scss";
@import "gui/_fieldset.scss";
@import "gui/_output.scss";
@import "gui/_hint.scss";
@import "gui/_listbox.scss";
@import "gui/_selectbox.scss";
......@@ -62,9 +63,3 @@ article p.text {
padding: 0.5em 1em;
}
article p.hint {
font-size: 1.1em;
padding: 0.5em 1em;
color: $text-color-hint;
text-align: center;
}
/*
Copyright (C) 2015 Michael Herold <quabla@hemio.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Created on : Nov 14, 2015, 4:15:02 PM
Author : Michael Herold <quabla@hemio.de>
*/
article p.hint {
font-size: 1.1em;
padding: 0.5em 1em;
color: $text-color-hint;
text-align: center;
}
/*
Copyright (C) 2015 Michael Herold <quabla@hemio.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Created on : Nov 14, 2015, 4:27:09 PM
Author : Michael Herold <quabla@hemio.de>
*/
input[type=radio].list {
position: absolute;
margin: 0;
padding: 0;
z-index: -2;
opacity: 0;
}
ul.radio li label {
background-color: $sidebar-selected-color;
color: white;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment