Skip to content

Commit

Permalink
Fixes #743 - Also, JS maps. (#747)
Browse files Browse the repository at this point in the history
* Fixes #743 - Also, JS maps.

* Implements #720

* Implements #669

* Fixes #558

* Adds #483
  • Loading branch information
adamdriscoll authored Apr 13, 2019
1 parent e365d3f commit 27f5dc6
Show file tree
Hide file tree
Showing 17 changed files with 216 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@
$JsFile = Get-ChildItem "$PSScriptRoot\index.*.bundle.js"
$JsFiles = Get-ChildItem "$PSScriptRoot\*.bundle.js"
$Maps = Get-ChildItem "$PSScriptRoot\*.bundle.map"
$CSSFile = Get-ChildItem "$PSScriptRoot\*.css"

# Register our style sheet with UD
[UniversalDashboard.Services.AssetService]::Instance.RegisterStyleSheet($CSSFile.FullName)

$JsFiles | ForEach-Object {
[UniversalDashboard.Services.AssetService]::Instance.RegisterScript($_.FullName)
[UniversalDashboard.Services.AssetService]::Instance.RegisterAsset($_.FullName)
}

$Maps | ForEach-Object {
[UniversalDashboard.Services.AssetService]::Instance.RegisterScript($_.FullName) | Out-Null
[UniversalDashboard.Services.AssetService]::Instance.RegisterAsset($_.FullName) | Out-Null
}

$MUAssetId = [UniversalDashboard.Services.AssetService]::Instance.RegisterScript($JSFile.FullName)
[UniversalDashboard.Services.AssetService]::Instance.RegisterFramework("MaterialUI", $MUAssetId)
$MUAssetId = [UniversalDashboard.Services.AssetService]::Instance.RegisterAsset($JSFile.FullName)
[UniversalDashboard.Services.AssetService]::Instance.RegisterFramework("MaterialUI", $JSFile.FullName)

# Load out controls
Get-ChildItem (Join-Path $PSScriptRoot "Scripts") -File -Filter "*.ps1" | ForEach-Object {
Expand Down
41 changes: 30 additions & 11 deletions src/UniversalDashboard.MaterialUI/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 33 additions & 1 deletion src/UniversalDashboard.Materialize/Components/ud-input-field.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@ import React from 'react';
import {Input as RInput} from 'react-materialize';
import {DebounceInput} from 'react-debounce-input';

// taken from https://davidwalsh.name/javascript-debounce-function
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
}

export default class UdInputField extends React.Component {

constructor() {
Expand Down Expand Up @@ -76,7 +92,7 @@ export default class UdInputField extends React.Component {
setupDatePicker() {
var comp = this;

$(this.datetime).pickadate({
this.picker = $(this.datetime).pickadate({
selectYears: 100,
clearText: this.props.clearText,
okText: this.props.okText,
Expand Down Expand Up @@ -117,6 +133,19 @@ export default class UdInputField extends React.Component {

if (this.props.type === 'date') {
this.setupDatePicker();

// Dirty hack to get this to work in Chrome
$("#" + this.props.name).unbind("click");
$("#" + this.props.name).unbind("focus");
$("#" + this.props.name).on("click", debounce(function(event) {
event.preventDefault()
this.picker.pickadate('picker').open()
}.bind(this), 100));

$("#" + this.props.name).on("focus", debounce(function(event) {
event.preventDefault()
this.picker.pickadate('picker').open()
}.bind(this), 100));
}

if (this.props.type === 'time') {
Expand Down Expand Up @@ -146,6 +175,9 @@ export default class UdInputField extends React.Component {
}
}




componentDidUpdate() {
this.updateTextField();

Expand Down
18 changes: 17 additions & 1 deletion src/UniversalDashboard.Materialize/Scripts/button.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ function New-UDButton {
[UniversalDashboard.Models.FontAwesomeIcons]$Icon,
[Parameter()]
[ValidateSet('left', 'right')]
[String]$IconAlignment = 'left'
[String]$IconAlignment = 'left',
[Parameter()]
[UniversalDashboard.Models.DashboardColor]$BackgroundColor,
[Parameter()]
[UniversalDashboard.Models.DashboardColor]$FontColor,
[Parameter()]
[Switch]$Disabled
)

$btnClass = 'btn'
Expand All @@ -26,9 +32,19 @@ function New-UDButton {
$btnClass = 'btn-flat'
}

if ($Disabled) {
$btnClass += ' disabled'
}

$style = @{
backgroundColor = $BackgroundColor.HtmlColor
color = $FontColor.HtmlColor
}

New-UDElement -Id $Id -Tag "a" -Attributes @{
className = "$btnClass"
onClick = $OnClick
style = $style
} -Content {
if ($Icon -ne $null) {
$faClass = $Icon.ToString().Replace('_', '-')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ $IndexJs = Get-ChildItem "$PSScriptRoot\index.*.bundle.js"
$JsFiles = Get-ChildItem "$PSScriptRoot\*.bundle.js"
$Maps = Get-ChildItem "$PSScriptRoot\*.map"

$AssetId = [UniversalDashboard.Services.AssetService]::Instance.RegisterScript($IndexJs.FullName)
$AssetId = [UniversalDashboard.Services.AssetService]::Instance.RegisterAsset($IndexJs.FullName)
[UniversalDashboard.Services.AssetService]::Instance.RegisterFramework("Materialize", $AssetId)

foreach($item in $JsFiles)
{
[UniversalDashboard.Services.AssetService]::Instance.RegisterScript($item.FullName) | Out-Null
[UniversalDashboard.Services.AssetService]::Instance.RegisterAsset($item.FullName) | Out-Null
}

foreach($item in $Maps)
{
[UniversalDashboard.Services.AssetService]::Instance.RegisterScript($item.FullName) | Out-Null
[UniversalDashboard.Services.AssetService]::Instance.RegisterAsset($item.FullName) | Out-Null
}

Get-ChildItem (Join-Path $PSScriptRoot "scripts") -File | ForEach-Object {
Expand Down
Loading

0 comments on commit 27f5dc6

Please sign in to comment.