mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-11 20:21:16 +00:00
better handling of date attributes
This commit is contained in:
parent
e3ce931cbd
commit
19144f3c73
|
@ -971,7 +971,13 @@ $(document).ready(function() {
|
|||
default:
|
||||
$options = [];
|
||||
foreach($values as $v=>$c) {
|
||||
$option = array($v, $v);
|
||||
switch($attrdef->getType()) {
|
||||
case SeedDMS_Core_AttributeDefinition::type_date:
|
||||
$option = array($v, getReadableDate($v));
|
||||
break;
|
||||
default:
|
||||
$option = array($v, $v);
|
||||
}
|
||||
if(isset($attributes[$facetname]) && in_array($v, $attributes[$facetname]))
|
||||
$option[] = true;
|
||||
else
|
||||
|
@ -1052,7 +1058,16 @@ $(document).ready(function() {
|
|||
echo '<input type="hidden" name="attributes['.$facetname.'][to]" value="'.$oldvalue['to'].'" />';
|
||||
}
|
||||
} else {
|
||||
$oldvalue = is_array($allparams['attributes'][$facetname]) ? implode(',', $allparams['attributes'][$facetname]) : $allparams['attributes'][$facetname];
|
||||
if(is_array($allparams['attributes'][$facetname])) {
|
||||
switch($attrdef->getType()) {
|
||||
case SeedDMS_Core_AttributeDefinition::type_date:
|
||||
array_walk($allparams['attributes'][$facetname], function(&$v, $k){$v=getReadableDate($v);});
|
||||
break;
|
||||
}
|
||||
$oldvalue = implode(',', $allparams['attributes'][$facetname]);
|
||||
} else {
|
||||
$oldvalue = $allparams['attributes'][$facetname];
|
||||
}
|
||||
unset($allparams['attributes'][$facetname]);
|
||||
$newrequest = Symfony\Component\HttpFoundation\Request::create($request->getBaseUrl(), 'GET', $allparams);
|
||||
$menuitems[] = array('label'=>'<i class="fa fa-remove"></i> '.$dispname.' = '.$oldvalue, 'link'=>$newrequest->getRequestUri(), 'attributes'=>[['title', 'Click to remove']], '_badge'=>'x');
|
||||
|
@ -1065,18 +1080,22 @@ $(document).ready(function() {
|
|||
$allparams = $request->query->all();
|
||||
if(isset($allparams[$facetname])) {
|
||||
$oldvalue = is_array($allparams[$facetname]) ? implode(',', $allparams[$facetname]) : $allparams[$facetname];
|
||||
switch($facetname) {
|
||||
case 'status':
|
||||
$oldtransval = getOverallStatusText($oldvalue);
|
||||
break;
|
||||
default:
|
||||
$oldtransval = $oldvalue;
|
||||
}
|
||||
unset($allparams[$facetname]);
|
||||
$newrequest = Symfony\Component\HttpFoundation\Request::create($request->getBaseUrl(), 'GET', $allparams);
|
||||
$menuitems[] = array('label'=>'<i class="fa fa-remove"></i> '.getMLText($facetname).' = '.$oldvalue, 'link'=>$newrequest->getRequestUri(), 'attributes'=>[['title', 'Click to remove']], '_badge'=>'x');
|
||||
$menuitems[] = array('label'=>'<i class="fa fa-remove"></i> '.getMLText($facetname).' = '.$oldtransval, 'link'=>$newrequest->getRequestUri(), 'attributes'=>[['title', 'Click to remove']], '_badge'=>'x');
|
||||
echo '<input type="hidden" name="'.$facetname.'[]" value="'.$oldvalue.'" />';
|
||||
}
|
||||
}
|
||||
}
|
||||
if($menuitems) {
|
||||
// ob_start();
|
||||
self::showNavigationListWithBadges($menuitems);
|
||||
// $content = ob_get_clean();
|
||||
// $this->printAccordion(getMLText('current_filter'), $content, true);
|
||||
}
|
||||
}
|
||||
echo "<p></p>";
|
||||
|
@ -1102,7 +1121,7 @@ $(document).ready(function() {
|
|||
if(empty($allparams['attributes'][$facetname]['from']) && empty($allparams['attributes'][$facetname]['to'])) {
|
||||
$tt = array_keys($values);
|
||||
$content = '<div class="input-group">';
|
||||
$content .= '<span class="input-group-text" style="border-left: 0; border-right: 0;"> from </span>';
|
||||
$content .= '<span class="input-group-text" style="border-right: 0;"> from </span>';
|
||||
$content .= '<input type="number" class="form-control" name="attributes['.$facetname.'][from]" value="" placeholder="min is '.min($tt).'" />';
|
||||
$content .= '<span class="input-group-text" style="border-left: 0; border-right: 0;"> to </span>';
|
||||
$content .= '<input type="number" class="form-control" name="attributes['.$facetname.'][to]" value="" placeholder="max is '.max($tt).'" />';
|
||||
|
@ -1112,13 +1131,34 @@ $(document).ready(function() {
|
|||
}
|
||||
}
|
||||
break;
|
||||
case SeedDMS_Core_AttributeDefinition::type_date:
|
||||
if($values && (count($values) > 1 || reset($values) < $total)) {
|
||||
if(empty($allparams['attributes'][$facetname]['from']) && empty($allparams['attributes'][$facetname]['to'])) {
|
||||
$tt = array_keys($values);
|
||||
$content = '<div class="input-group">';
|
||||
$content .= '<span class="input-group-text" style="border-right: 0;"> from </span>';
|
||||
$content .= $this->getDateChooser('', "attributes[".$facetname."][from]", $this->params['session']->getLanguage(), '', getReadableDate(min($tt)), getReadableDate(max($tt)));
|
||||
$content .= '<span class="input-group-text" style="border-left: 0; border-right: 0;"> to </span>';
|
||||
$content .= $this->getDateChooser('', "attributes[".$facetname."][to]", $this->params['session']->getLanguage(), '', getReadableDate(min($tt)), getReadableDate(max($tt)));
|
||||
$content .= '<button class="btn btn-primary" type="submit">Set</button>';
|
||||
$content .= '</div>';
|
||||
$this->printAccordion($dispname, $content);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* See below on an explaination for the if statement */
|
||||
if($values && (count($values) > 1 || reset($values) < $total)) {
|
||||
$menuitems = array();
|
||||
arsort($values);
|
||||
foreach($values as $v=>$c) {
|
||||
$menuitems[] = array('label'=>htmlspecialchars($v), 'link'=>$newrequest->getRequestUri().'&attributes['.$facetname.'][]='.urlencode($v), 'badge'=>$c);
|
||||
switch($attrdef->getType()) {
|
||||
case SeedDMS_Core_AttributeDefinition::type_date:
|
||||
$menuitems[] = array('label'=>getReadableDate($v), 'link'=>$newrequest->getRequestUri().'&attributes['.$facetname.'][]='.urlencode($v), 'badge'=>$c);
|
||||
break;
|
||||
default:
|
||||
$menuitems[] = array('label'=>htmlspecialchars($v), 'link'=>$newrequest->getRequestUri().'&attributes['.$facetname.'][]='.urlencode($v), 'badge'=>$c);
|
||||
}
|
||||
}
|
||||
ob_start();
|
||||
self::showNavigationListWithBadges($menuitems);
|
||||
|
@ -1136,8 +1176,16 @@ $(document).ready(function() {
|
|||
if($values && (count($values) > 1 || reset($values) < $total)) {
|
||||
$menuitems = array();
|
||||
arsort($values);
|
||||
foreach($values as $v=>$c) {
|
||||
$menuitems[] = array('label'=>htmlspecialchars($v), 'link'=>$newrequest->getRequestUri().'&'.$facetname.'[]='.urlencode($v), 'badge'=>$c);
|
||||
switch($facetname) {
|
||||
case 'status':
|
||||
foreach($values as $v=>$c) {
|
||||
$menuitems[] = array('label'=>getOverallStatusText($v), 'link'=>$newrequest->getRequestUri().'&'.$facetname.'[]='.urlencode($v), 'badge'=>$c);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
foreach($values as $v=>$c) {
|
||||
$menuitems[] = array('label'=>htmlspecialchars($v), 'link'=>$newrequest->getRequestUri().'&'.$facetname.'[]='.urlencode($v), 'badge'=>$c);
|
||||
}
|
||||
}
|
||||
ob_start();
|
||||
self::showNavigationListWithBadges($menuitems);
|
||||
|
|
Loading…
Reference in New Issue
Block a user