Skip to content

Instantly share code, notes, and snippets.

View davecra's full-sized avatar
💭
Coding for arrays

David E. Craig davecra

💭
Coding for arrays
View GitHub Profile
@davecra
davecra / etag.js
Created November 10, 2023 03:13
Converts an @odata.etag
const updatedTag = eTag.replace('W/"', '"').replace('\\"', "");
@davecra
davecra / ref.js
Created November 10, 2023 03:11
Creates a new reference for a Planner Task Attachment
const ref = {
/** @type {PlannerReference} */
[this.#encodePlannerExternalReferenceUrl(driveItem.webUrl)]: {
"@odata.type": "#microsoft.graph.plannerExternalReference",
alias: name,
type: "Other",
},
};
@davecra
davecra / enocdePlannerUrl.js
Created November 10, 2023 03:04
Encodes a URL in a format the Graph API References will accept
/**
* Encodes the URL ins the special planner format that is for oif but not quite
* following the encodeURIComponent() specification...
* @param {String} url
* @returns {String}
*/
#encodePlannerExternalReferenceUrl = (url) => {
// Encode specific characters: : . _
const encodedUrl = url.replace(/:/g, "%3A").replace(/\./g, "%2E").replace(/ /g, "%20");
return encodedUrl;
@davecra
davecra / client.js
Created October 22, 2023 20:20
Procured Board Button
/// <reference path="trello.d.js" />
/** @type {TrelloPowerUp} */
const tpu = window.TrelloPowerUp;
tpu.initialize({
'board-buttons':
/**
* Returns the board button
* @param {TrelloObject} t
* @returns {TrelloBoardButtonOption[]}
*/
@davecra
davecra / webpack.config.js
Created October 22, 2023 20:04
Webpack.config.js for Power-Up
const CopyWebpackPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const fs = require("fs");
module.exports = async (env, options) => {
const isProduction = options.mode === 'production';
const config = {
devtool: isProduction ? false : 'source-map',
mode: isProduction ? "production" : "development",
entry: {
details: "./js/details.js",
@davecra
davecra / package.json
Created October 22, 2023 20:03
Package.json for Power-Up
{
"name": "trello-hello-world",
"appName": "Hello World",
"version": "1.0",
"description": "A Power-Up to say hello.",
"scripts": {
"start": "webpack-dev-server --mode development",
"build": "node webpack --mode production"
},
"dependencies": {
@davecra
davecra / settingsPage.js
Created October 22, 2023 20:01
settingsPage for Power-Up
/// <reference path="../../types/trello.d.js" />
import Common from "../common/common";
export default class SettingsPage {
constructor() { }
/**
* Renders the settings page
* @param {TrelloObject} t
*/
render = async (t) => {
/** @type {String} */
@davecra
davecra / details.js
Created October 22, 2023 20:00
Details.js for Power-Up
/* global TrelloPowerUp */
/// <reference path="../types/trello.d.js" />
import SettingsPage from "./pages/settingsPage";
/** @type {TrelloPowerUp} */
const tpu = window.TrelloPowerUp;
/** @type {TrelloObject} Trello iframe object */
const t = tpu.iframe();
t.render(() => {
/** @type { "settings" } */
const page = t.arg("page");
@davecra
davecra / client.js
Created October 22, 2023 19:58
Client.js for Power-Up
/* global TrelloPowerUp */
/// <reference path="../types/trello.d.js" />
import Common from './common/common';
/** @type {TrelloPowerUp} */
const tpu = window.TrelloPowerUp;
tpu.initialize({
'board-buttons': async (t) => await getBoardButton(t),
});
/**
* Returns the board button
@davecra
davecra / common.js
Created October 22, 2023 19:57
Common.js for Power-Up
const PACKAGE = require('../../package.json');
/**
* CommonFunctions to be shared across all the project
*/
export default class Common {
/** @type {String} */
static APPNAME = PACKAGE.appName;
/** @type {String} */
static VERSION = PACKAGE.version;
/** @type {String} */