SPRINT-12: added stepper widget, added linkability to table widget

This commit is contained in:
Tim Chamberlain
2022-09-29 12:04:24 -05:00
parent 720200b6cf
commit 8a1110abf0
4 changed files with 417 additions and 1 deletions

View File

@ -37,7 +37,7 @@ import com.kingsrook.qqq.backend.core.model.actions.widgets.RenderWidgetOutput;
public abstract class AbstractWidgetRenderer public abstract class AbstractWidgetRenderer
{ {
public static final QValueFormatter valueFormatter = new QValueFormatter(); public static final QValueFormatter valueFormatter = new QValueFormatter();
public static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd H:mma").withZone(ZoneId.systemDefault()); public static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd h:mma").withZone(ZoneId.systemDefault());
public static final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()); public static final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault());

View File

@ -0,0 +1,302 @@
/*
* QQQ - Low-code Application Framework for Engineers.
* Copyright (C) 2021-2022. Kingsrook, LLC
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
* contact@kingsrook.com
* https://github.com/Kingsrook/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.kingsrook.qqq.backend.core.model.dashboard.widgets;
import java.util.List;
/*******************************************************************************
** Model containing datastructure expected by frontend stepper widget
**
*******************************************************************************/
public class StepperData implements QWidget
{
private String title;
private int activeStep;
private List<Step> steps;
/*******************************************************************************
**
*******************************************************************************/
public StepperData(String title, int activeStep, List<Step> steps)
{
this.title = title;
this.activeStep = activeStep;
this.steps = steps;
}
/*******************************************************************************
** Getter for type
**
*******************************************************************************/
public String getType()
{
return "stepper";
}
/*******************************************************************************
** Getter for title
**
*******************************************************************************/
public String getTitle()
{
return title;
}
/*******************************************************************************
** Setter for title
**
*******************************************************************************/
public void setTitle(String title)
{
this.title = title;
}
/*******************************************************************************
** Fluent setter for title
**
*******************************************************************************/
public StepperData withTitle(String title)
{
this.title = title;
return (this);
}
/*******************************************************************************
** Getter for activeStep
**
*******************************************************************************/
public int getActiveStep()
{
return activeStep;
}
/*******************************************************************************
** Setter for activeStep
**
*******************************************************************************/
public void setActiveStep(int activeStep)
{
this.activeStep = activeStep;
}
/*******************************************************************************
** Fluent setter for activeStep
**
*******************************************************************************/
public StepperData withActiveStep(int activeStep)
{
this.activeStep = activeStep;
return (this);
}
/*******************************************************************************
** Getter for steps
**
*******************************************************************************/
public List<Step> getSteps()
{
return steps;
}
/*******************************************************************************
** Setter for steps
**
*******************************************************************************/
public void setSteps(List<Step> steps)
{
this.steps = steps;
}
/*******************************************************************************
** Fluent setter for steps
**
*******************************************************************************/
public StepperData withSteps(List<Step> steps)
{
this.steps = steps;
return (this);
}
/*******************************************************************************
**
*******************************************************************************/
public static class Step
{
private String label;
private String linkText;
private String linkURL;
/*******************************************************************************
**
*******************************************************************************/
public Step()
{
this.label = label;
this.linkText = linkText;
this.linkURL = linkURL;
}
/*******************************************************************************
**
*******************************************************************************/
public Step(String label, String linkText, String linkURL)
{
this.label = label;
this.linkText = linkText;
this.linkURL = linkURL;
}
/*******************************************************************************
** Getter for label
**
*******************************************************************************/
public String getLabel()
{
return label;
}
/*******************************************************************************
** Setter for label
**
*******************************************************************************/
public void setLabel(String label)
{
this.label = label;
}
/*******************************************************************************
** Fluent setter for label
**
*******************************************************************************/
public Step withLabel(String label)
{
this.label = label;
return (this);
}
/*******************************************************************************
** Getter for linkText
**
*******************************************************************************/
public String getLinkText()
{
return linkText;
}
/*******************************************************************************
** Setter for linkText
**
*******************************************************************************/
public void setLinkText(String linkText)
{
this.linkText = linkText;
}
/*******************************************************************************
** Fluent setter for linkText
**
*******************************************************************************/
public Step withLinkText(String linkText)
{
this.linkText = linkText;
return (this);
}
/*******************************************************************************
** Getter for linkURL
**
*******************************************************************************/
public String getLinkURL()
{
return linkURL;
}
/*******************************************************************************
** Setter for linkURL
**
*******************************************************************************/
public void setLinkURL(String linkURL)
{
this.linkURL = linkURL;
}
/*******************************************************************************
** Fluent setter for linkURL
**
*******************************************************************************/
public Step withLinkURL(String linkURL)
{
this.linkURL = linkURL;
return (this);
}
}
}

View File

@ -33,6 +33,8 @@ import java.util.Map;
public class TableData implements QWidget public class TableData implements QWidget
{ {
private String title; private String title;
private String linkText;
private String linkURL;
private String noRowsFoundHTML; private String noRowsFoundHTML;
private List<Column> columns; private List<Column> columns;
private List<Map<String, Object>> rows; private List<Map<String, Object>> rows;
@ -234,6 +236,74 @@ public class TableData implements QWidget
/*******************************************************************************
** Getter for linkText
**
*******************************************************************************/
public String getLinkText()
{
return linkText;
}
/*******************************************************************************
** Setter for linkText
**
*******************************************************************************/
public void setLinkText(String linkText)
{
this.linkText = linkText;
}
/*******************************************************************************
** Fluent setter for linkText
**
*******************************************************************************/
public TableData withLinkText(String linkText)
{
this.linkText = linkText;
return (this);
}
/*******************************************************************************
** Getter for linkURL
**
*******************************************************************************/
public String getLinkURL()
{
return linkURL;
}
/*******************************************************************************
** Setter for linkURL
**
*******************************************************************************/
public void setLinkURL(String linkURL)
{
this.linkURL = linkURL;
}
/*******************************************************************************
** Fluent setter for linkURL
**
*******************************************************************************/
public TableData withLinkURL(String linkURL)
{
this.linkURL = linkURL;
return (this);
}
/******************************************************************************* /*******************************************************************************
** **
*******************************************************************************/ *******************************************************************************/

View File

@ -201,6 +201,50 @@ public class ValueUtils
/*******************************************************************************
** Type-safely make a LocalDateTime from any Object.
** null and empty-string inputs return null.
** We may throw if the input can't be converted to a LocalDateTime
*******************************************************************************/
public static LocalDateTime getValueAsLocalDateTime(Object value) throws QValueException
{
try
{
if(value == null)
{
return (null);
}
else if(value instanceof LocalDateTime ldt)
{
return (ldt);
}
else if(value instanceof java.sql.Timestamp ts)
{
return ts.toLocalDateTime();
}
else if(value instanceof Calendar c)
{
TimeZone tz = c.getTimeZone();
ZoneId zid = (tz == null) ? ZoneId.systemDefault() : tz.toZoneId();
return LocalDateTime.ofInstant(c.toInstant(), zid);
}
else
{
throw (new QValueException("Unsupported class " + value.getClass().getName() + " for converting to LocalDateTime."));
}
}
catch(QValueException qve)
{
throw (qve);
}
catch(Exception e)
{
throw (new QValueException("Value [" + value + "] could not be converted to a LocalDateTime.", e));
}
}
/******************************************************************************* /*******************************************************************************
** Type-safely make a LocalDate from any Object. ** Type-safely make a LocalDate from any Object.
** null and empty-string inputs return null. ** null and empty-string inputs return null.