Skip to content

Instantly share code, notes, and snippets.

@sancarn
Created May 22, 2025 16:32
Show Gist options
  • Save sancarn/21ffd92731f9eb00d6ccbd12cf8310a2 to your computer and use it in GitHub Desktop.
Save sancarn/21ffd92731f9eb00d6ccbd12cf8310a2 to your computer and use it in GitHub Desktop.
Screens:
SPS Checklist:
Properties:
LoadingSpinnerColor: =RGBA(56, 96, 178, 1)
OnVisible: |-
=ClearCollect(myResults, {ID: "", Title: "", Type: "", SortNum: 0, JSON: ""});
Remove(myResults, First(myResults));
UpdateContext({VisibleMode: Blank()})
Children:
- EditPumpDetails:
Control: [email protected]
Variant: ManualLayout
Properties:
Fill: =RGBA(255, 255, 255, 1)
Height: =1055
Visible: =VisibleMode = "EditPumpItem"
Width: =640
Y: =81
Children:
- inptPowerRating:
Control: CanvasComponent
ComponentName: TextInput
Properties:
Default: =ParseJSON(ThisPumpData).PowerRating
- inptPumpPlate:
Control: CanvasComponent
ComponentName: ImageInput
Properties:
Default: |-
=With(
{img: ParseJSON(ThisPumpData).Image & ""},
If(img="",SampleImage, img)
)
Description: =""
OnChange: |-
={ID: inptPumpPlate.ChangeID, Title: inptPumpPlate.Title, Value: {Name: "", DataURI: ""}}
- btnSubmit:
Control: Classic/[email protected]
Properties:
OnSelect: |-
=PumpInfo.UpdateItem(
ThisPumpIndex,
JSON(
{
PowerRating: inptPowerRating.Value,
Image: inptPumpPlate.GetValue().DataURI
}
)
);
Reset(inptPumpPlate);
UpdateContext({VisibleMode: Blank()});
- btnCancel:
Control: Classic/[email protected]
Properties:
OnSelect: |-
=Reset(inptPumpPlate);
UpdateContext({VisibleMode: Blank()});
- btnDelete:
Control: Classic/[email protected]
Properties:
BorderColor: =ColorFade(Self.Fill, -15%)
Color: =RGBA(255, 255, 255, 1)
DisabledBorderColor: =RGBA(166, 166, 166, 1)
Fill: =RGBA(168, 0, 0, 1)
Font: =Font.'Open Sans'
Height: =86
HoverBorderColor: =ColorFade(Self.BorderColor, 20%)
HoverColor: =RGBA(255, 255, 255, 1)
HoverFill: =ColorFade(RGBA(56, 96, 178, 1), -20%)
OnSelect: |-
=PumpInfo.DeleteItem(
ThisPumpIndex
);
Reset(inptPumpPlate);
UpdateContext({VisibleMode: Blank()});
PressedBorderColor: =Self.Fill
PressedColor: =Self.Fill
PressedFill: =Self.Color
Text: ="Delete"
Width: =138
X: =22
Y: =859
- Questions:
Control: [email protected]
Variant: AutoLayout
Properties:
Height: =1055
LayoutDirection: =LayoutDirection.Vertical
LayoutOverflowY: =LayoutOverflow.Scroll
Visible: =IsBlank(VisibleMode)
Width: =640
Y: =81
Children:
- ...
- PumpInfo:
Control: CanvasComponent
ComponentName: DynamicGalleryInput_2
Properties:
ChangeID: =GUID()
Description: ="Please add all pumps and assign power ratings and pictures of the pump plates."
InputItems: |-
=Table(
[
{
Type: "",
ID: "",
SortNum: 0,
Title: "",
Value: [
{
Index: 0,
Metadata: ParseJSON("")
}
],
JSON: ""
}
]
)
OnChange: |-
=Patch(
myResults,
Coalesce(LookUp(myResults, ID = ThisResult.ID), Defaults(myResults)),
{
ID: ThisResult.ID,
Title: ThisResult.Title,
SortNum: ThisResult.SortNum,
Type: ThisResult.Type,
JSON: ThisResult.JSON
}
)
OnCreateItem: =
OnSelect: |-
=UpdateContext({
VisibleMode: "EditPumpItem",
ThisPumpIndex: ThisItemIndex,
ThisPumpData: ThisItemMetadata
})
Render: |-
=With(
{
image: Coalesce(ParseJSON(ThisItem).Image, Blank()),
power: Coalesce(ParseJSON(ThisItem).PowerRating, Blank())
},
{
Title: "Pump " & ThisItemIndex,
Description: "PowerRating: " & If(IsBlank(power),"Unknown", power & "kw"),
Image: If(IsBlank(image),"",image)
}
)
SortNum: =100
Title: ="Pump Information"
Validation: |-
=Table({Type: "Warn", Text: "Hello warning"})
isDescriptionHTML: =true
- ...
- AppTitle:
Control: [email protected]
Properties:
Align: =Align.Center
BorderColor: =RGBA(0, 18, 107, 1)
Color: =RGBA(255, 255, 255, 1)
Fill: =RGBA(0, 18, 107, 1)
Font: =Font.'Open Sans'
Height: =81
Size: =30
Text: |-
="SPS CHECKLIST
"
Width: =640
ComponentDefinitions:
DynamicGalleryInput_2:
DefinitionType: CanvasComponent
CustomProperties:
ChangeID:
PropertyKind: Input
DisplayName: ChangeID
Description: ID to include in OnChange event
DataType: Text
Default: =GUID()
DeleteItem:
PropertyKind: Action
DisplayName: DeleteItem
Description: 'Delete an item at a position. Type: (index: number) => void'
ReturnType: None
Parameters:
- Index:
Description: The index to remove
DataType: Number
Default: =100
Description:
PropertyKind: Input
DisplayName: Description
Description: A custom property
DataType: Text
Default: ="Text"
InputItems:
PropertyKind: Input
DisplayName: Input Items
Description: 'A table of JSON payloads to hold the record data. JSON strings are used to get around the strong type system of PowerApps. Type: Table([{raw: string}])'
RaiseOnReset: true
DataType: Table
Default: |-
=Table(
[
{
Type: "",
ID: "",
SortNum: 0,
Title: "",
Value: [
{
Index: 0,
Metadata: ParseJSON("")
}
],
JSON: ""
}
]
)
OnChange:
PropertyKind: Event
DisplayName: OnChange
Description: Event raised whenever a change is made
ReturnType: None
Default: =
Parameters:
- ThisResult:
Description: A parameter
DataType: Record
Default: |-
=With(
{
cleanItems: ForAll(
_itemsDynamicGalleryInput56ca79336be24d748b7d975210c644bb,
{
Index: ThisRecord.index,
Metadata: ParseJSON(ThisRecord.metadata)
}
)
},
{
Type: "GalleryInput",
ID: "",
SortNum: 0,
Title: "",
Value: cleanItems,
JSON: ""
}
)
OnCreateItem:
PropertyKind: Event
DisplayName: OnCreateItem
Description: 'An event triggers when items added to the gallery. Record is always {} on create. Type: (Index: number)=>void'
ReturnType: None
Default: =
Parameters:
- ThisItemIndex:
Description: The index of the item that was added
DataType: Number
Default: =100
OnSelect:
PropertyKind: Event
DisplayName: OnSelect
Description: 'When an item is selected from the gallery. Type: (ThisRecord: string) => void'
ReturnType: None
Default: =
Parameters:
- ThisItemMetadata:
Description: " The selected record"
DataType: Text
Default: ="Text"
- ThisItemIndex:
Description: The index of the selected row
DataType: Number
Default: =100
Render:
PropertyKind: InputFunction
DisplayName: Render
Description: Returns rendering information
DataType: Record
Default: |-
={Title: "", Description: "", Image: ""}
Parameters:
- ThisItemIndex:
Description: The index of the item
DataType: Number
Default: =100
- ThisItem:
Description: A JSON payload containing data for the record
DataType: Text
Default: ="Text"
SortNum:
PropertyKind: Input
DisplayName: SortNum
Description: Index to sort result at
DataType: Number
Default: =100
Title:
PropertyKind: Input
DisplayName: Title
Description: A custom property
DataType: Text
Default: ="Text"
UpdateItem:
PropertyKind: Action
DisplayName: UpdateItem
Description: 'Update an item in the gallery. Type: (index: number, Metadata: string) => void'
ReturnType: None
Parameters:
- Index:
Description: Index of item to update
DataType: Number
Default: =100
- Metadata:
Description: Data of item to update item to
DataType: Text
Default: ="Text"
Validation:
PropertyKind: InputFunction
DisplayName: Validation
Description: A custom property
DataType: Table
Default: |-
=Table({Type: "Warn", Text: "Hello warning"})
Parameters:
- ThisItem:
Description: A parameter
DataType: Text
Default: ="Text"
isDescriptionHTML:
PropertyKind: Input
DisplayName: isDescriptionHTML
Description: A custom property
DataType: Boolean
Default: =true
Properties:
DeleteItem: |-
=// Remove the item at the specified index
Remove(
_itemsDynamicGalleryInput56ca79336be24d748b7d975210c644bb,
Index(_itemsDynamicGalleryInput56ca79336be24d748b7d975210c644bb, Index)
);
// Clear and reindex the remaining items
ClearCollect(
_itemsDynamicGalleryInput56ca79336be24d748b7d975210c644bb,
ForAll(
Sequence(CountRows(_itemsDynamicGalleryInput56ca79336be24d748b7d975210c644bb)),
Patch(
Index(_itemsDynamicGalleryInput56ca79336be24d748b7d975210c644bb, Value),
{ index: Value }
)
)
);
With(
{
cleanItems: ForAll(
_itemsDynamicGalleryInput56ca79336be24d748b7d975210c644bb,
{
Index: ThisRecord.index,
Metadata: ParseJSON(ThisRecord.metadata)
}
)
},
With(
{
record: {
Type: "GalleryInput",
ID: DynamicGalleryInput_2.ChangeID,
SortNum: DynamicGalleryInput_2.SortNum,
Title: DynamicGalleryInput_2.Title,
Value: cleanItems
}
},
DynamicGalleryInput_2.OnChange(
Patch(
record,
{JSON: JSON(record)}
)
)
)
);
OnReset: |+
=Clear(_itemsDynamicGalleryInput56ca79336be24d748b7d975210c644bb);
ForAll(
Sequence(CountRows(DynamicGalleryInput_2.InputItems)),
Collect(
_itemsDynamicGalleryInput56ca79336be24d748b7d975210c644bb,
Patch(
Index(DynamicGalleryInput_2.InputItems, Value),
{ index: Value}
)
)
)
UpdateItem: |-
=Patch(
_itemsDynamicGalleryInput56ca79336be24d748b7d975210c644bb,
Index(_itemsDynamicGalleryInput56ca79336be24d748b7d975210c644bb, Index),
{metadata: Metadata}
);
With(
{
cleanItems: ForAll(
_itemsDynamicGalleryInput56ca79336be24d748b7d975210c644bb,
{
Index: ThisRecord.index,
Metadata: ParseJSON(ThisRecord.metadata)
}
)
},
With(
{
record: {
Type: "GalleryInput",
ID: DynamicGalleryInput_2.ChangeID,
SortNum: DynamicGalleryInput_2.SortNum,
Title: DynamicGalleryInput_2.Title,
Value: cleanItems
}
},
DynamicGalleryInput_2.OnChange(
Patch(
record,
{JSON: JSON(record)}
)
)
)
);
Children:
- DynGalleryInput_Container_2:
Control: [email protected]
Variant: AutoLayout
Properties:
Height: =DynamicGalleryInput_2.Height
LayoutDirection: =LayoutDirection.Vertical
Width: =DynamicGalleryInput_2.Width
Children:
- DynGalleryInput_HorizCont_2:
Control: [email protected]
Variant: AutoLayout
Properties:
FillPortions: =0
Height: =160
LayoutDirection: =LayoutDirection.Horizontal
Children:
- DynGalleryInput_DescCont_2:
Control: [email protected]
Variant: AutoLayout
Properties:
FillPortions: =0
Height: =100
LayoutDirection: =LayoutDirection.Vertical
LayoutJustifyContent: =LayoutJustifyContent.Center
LayoutMinHeight: =60
Width: =DynGalleryInput_HorizCont_2.Width-DynGalleryInput_AddCont_2.Width
Children:
- DynGalleryInput_Title_2:
Control: [email protected]
Properties:
AutoHeight: =true
BorderColor: =RGBA(0, 18, 107, 1)
Font: =Font.'Open Sans'
FontWeight: =FontWeight.Bold
Text: =DynamicGalleryInput_2.Title
Width: =DynGalleryInput_Container_2.Width
X: =40
Y: =40
- DynGalleryInput_Description_2:
Control: [email protected]
Properties:
AutoHeight: =true
Font: =Font.'Open Sans'
HtmlText: =Substitute(If(DynamicGalleryInput_2.isDescriptionHTML, "$root", "<p>$root</p>"), "$root", DynamicGalleryInput_2.Description)
Size: =14
Width: =DynGalleryInput_DescCont_2.Width
X: =5
Y: =70
- DynGalleryInput_AddCont_2:
Control: [email protected]
Variant: AutoLayout
Properties:
FillPortions: =0
LayoutDirection: =LayoutDirection.Vertical
LayoutJustifyContent: =LayoutJustifyContent.Center
Width: =150
Children:
- DynGalleryInput_AddBtn_2:
Control: Classic/[email protected]
Properties:
AlignInContainer: =AlignInContainer.Center
BorderColor: =RGBA(0, 18, 107, 1)
Color: =RGBA(0, 18, 107, 1)
Height: =DynGalleryInput_AddCont_2.Height
Icon: =Icon.Add
OnSelect: "=With(\n {newIndex: CountRows(_itemsDynamicGalleryInput56ca79336be24d748b7d975210c644bb) + 1},\n Collect(\n _itemsDynamicGalleryInput56ca79336be24d748b7d975210c644bb,\n {\n index: newIndex,\n metadata: \"{}\"\n }\n );\n DynamicGalleryInput_2.OnCreateItem(newIndex);\n \n);\nWith(\n {\n cleanItems: ForAll(\n _itemsDynamicGalleryInput56ca79336be24d748b7d975210c644bb,\n {\n Index: ThisRecord.index,\n Metadata: ParseJSON(ThisRecord.metadata)\n }\n )\n },\n With(\n {\n record: {\n Type: \"GalleryInput\",\n ID: DynamicGalleryInput_2.ChangeID,\n SortNum: DynamicGalleryInput_2.SortNum,\n Title: DynamicGalleryInput_2.Title,\n Value: cleanItems\n }\n },\n DynamicGalleryInput_2.OnChange(\n Patch(\n record,\n {JSON: JSON(record)}\n )\n )\n )\n);\n"
PressedFill: =RGBA(240,240,255,1)
Width: =DynGalleryInput_AddCont_2.Width
- DynGalleryInput_Gallery_2:
Control: [email protected]
Variant: BrowseLayout_Vertical_TwoTextOneImageVariant_ver5.0
Properties:
BorderColor: =RGBA(0, 18, 107, 1)
Items: =_itemsDynamicGalleryInput56ca79336be24d748b7d975210c644bb
OnSelect: =DynamicGalleryInput_2.OnSelect(ThisItem.metadata, ThisItem.index)
Children:
- DynGalleryItemIndex_2:
Control: [email protected]
Properties:
BorderColor: =RGBA(0, 18, 107, 1)
Color: =RGBA(166, 166, 166, 1)
Font: =Font.'Open Sans'
Height: =DynGalleryInput_Gallery_2.TemplateHeight
OnSelect: =Select(Parent)
Text: =ThisItem.index
Width: =30
- DynGalleryItemName_2:
Control: [email protected]
Properties:
BorderColor: =RGBA(0, 18, 107, 1)
Font: =Font.'Open Sans'
FontWeight: =FontWeight.Bold
Height: =DynGalleryInput_Gallery_2.TemplateHeight/3
OnSelect: =Select(Parent)
Size: =14
Text: =DynamicGalleryInput_2.Render(ThisItem.index, ThisItem.metadata).Title
Underline: =true
Width: =400
X: =DynGalleryItemIndex_2.X + DynGalleryItemIndex_2.Width
- DynGalleryItemImage_2:
Control: [email protected]
Properties:
BorderColor: =RGBA(0, 18, 107, 1)
Height: =DynGalleryInput_Gallery_2.TemplateHeight
Image: |-
=With(
{imageData: DynamicGalleryInput_2.Render(ThisItem.index, ThisItem.metadata).Image},
If(imageData<>"", imageData, SampleImage)
)
OnSelect: =Select(Parent)
Width: =150
X: =DynGalleryItemName_2.X+DynGalleryItemName_2.Width
- DynGalleryItemEditBtn_2:
Control: Classic/[email protected]
Properties:
BorderColor: =RGBA(0, 18, 107, 1)
Color: =RGBA(0, 18, 107, 1)
Height: =DynGalleryInput_Gallery_2.TemplateHeight
Icon: =Icon.NextArrow
OnSelect: =Select(Parent)
Width: =DynGalleryInput_Gallery_2.Width - (DynGalleryItemImage_2.X+DynGalleryItemImage_2.Width)
X: =DynGalleryItemImage_2.X+DynGalleryItemImage_2.Width
- DynGalleryItemDesc_2:
Control: [email protected]
Properties:
BorderColor: =RGBA(0, 18, 107, 1)
Font: =Font.'Open Sans'
FontWeight: =FontWeight.Lighter
Height: =DynGalleryInput_Gallery_2.TemplateHeight*2/3
OnSelect: =Select(Parent)
Size: =14
Text: =DynamicGalleryInput_2.Render(ThisItem.index, ThisItem.metadata).Description
VerticalAlign: =VerticalAlign.Top
Width: =DynGalleryItemName_2.Width
X: =DynGalleryItemName_2.X
Y: =DynGalleryInput_Gallery_2.TemplateHeight/3
- DynGalleryItemSeperator_2:
Control: [email protected]
Properties:
BorderColor: =RGBA(0, 18, 107, 1)
Fill: =RGBA(0, 18, 107, 1)
Height: =1
OnSelect: =Select(Parent)
Width: =Parent.TemplateWidth
Y: =Parent.TemplateHeight - Self.Height
- DynamicGalleryInput_AutoChange_2:
Control: [email protected]
Properties:
AutoStart: =true
BorderColor: =ColorFade(Self.Fill, -15%)
Color: =RGBA(255, 255, 255, 1)
DisabledBorderColor: =ColorFade(Self.BorderColor, 70%)
DisabledColor: =ColorFade(Self.Fill, 90%)
DisabledFill: =ColorFade(Self.Fill, 70%)
Duration: =10
Fill: =RGBA(56, 96, 178, 1)
Font: =Font.'Open Sans'
HoverBorderColor: =ColorFade(Self.BorderColor, 20%)
HoverColor: =RGBA(255, 255, 255, 1)
HoverFill: =ColorFade(RGBA(56, 96, 178, 1), -20%)
OnTimerEnd: |-
=With(
{
cleanItems: ForAll(
_itemsDynamicGalleryInput56ca79336be24d748b7d975210c644bb,
{
Index: ThisRecord.index,
Metadata: ParseJSON(ThisRecord.metadata)
}
)
},
With(
{
record: {
Type: "GalleryInput",
ID: DynamicGalleryInput_2.ChangeID,
SortNum: DynamicGalleryInput_2.SortNum,
Title: DynamicGalleryInput_2.Title,
Value: cleanItems
}
},
DynamicGalleryInput_2.OnChange(
Patch(
record,
{JSON: JSON(record)}
)
)
)
);
PressedBorderColor: =Self.Fill
PressedColor: =Self.Fill
PressedFill: =Self.Color
Visible: =false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment