Skip to content
This repository has been archived by the owner on Jan 4, 2025. It is now read-only.

Commit

Permalink
Fixes #743 - Also, JS maps.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdriscoll committed Apr 12, 2019
1 parent e365d3f commit 7ce42ad
Show file tree
Hide file tree
Showing 12 changed files with 175 additions and 97 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
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 7ce42ad

Please sign in to comment.