Skip to content

Instantly share code, notes, and snippets.

View cschuff's full-sized avatar

Christian Schuff cschuff

  • Christian Schuff IT-Consulting
  • Mannheim, Germany
View GitHub Profile
@cschuff
cschuff / ApiQuery
Created January 7, 2021 10:42
mimick nestjsx/crud query params
@ApiQuery({
isArray: true,
name: 'sort',
description: `Adds sort by field ('[field]||[ASC|DESC]'). <a href="https://github.com/nestjsx/crud/wiki/Requests#sort" target="_blank">Docs</a>`,
required: false,
schema: {
type: 'array',
items: {
example: 'createdAt||ASC',
type: 'string',
@cschuff
cschuff / SAPUI5ResourceBundles.js
Created March 1, 2018 13:27
Accessing SAPUI resource bundles
// see https://github.com/SAP/openui5/blob/83705d64d724275eb5bbba6d08bac91829b6a39f/src/sap.ui.core/test/sap/ui/core/qunit/Core.qunit.html
// see https://github.com/SAP/openui5/blob/master/src/sap.ui.core/src/sap/ui/core/messagebundle_de.properties
var sBundle = sap.ui.getCore().getLibraryResourceBundle("sap.ui.core", "de");
var sText = oBundle.getText("SAPUI5_FRIDAY");
@cschuff
cschuff / CLDR.js
Created March 1, 2018 13:25
Accessing SAPUI5 CLDR Resources
// see https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.ui.core.LocaleData.html
// see https://github.com/SAP/openui5/blob/master/src/sap.ui.core/src/sap/ui/core/cldr/de.json
var data = jQuery.sap.loadResource("sap/ui/core/cldr/de.json", {
dataType: "json",
failOnError : false
});
var hourNarrow = data.dateFields["hour-narrow"].displayName;
@cschuff
cschuff / package.json
Last active June 19, 2018 09:03
Minimal Express.js server for local SAPUI5 development. Proxies framework sources as well as backend services with no project source adjustments! Also works for SAP Web IDE projects. Run with '$ npm start'.
{
"name": "ui5-experts-servergist",
"version": "1.0.0",
"description": "",
"main": "server.js",
"author": {
"name": "Christian Schuff",
"email": "christian.schuff@ui5experts.com",
"url": "http://www.ui5experts.com"
},
@cschuff
cschuff / XMLViewBindingContexts.xml
Last active December 1, 2017 11:38
This gist shows how to set a binding contexts in SAPUI5 resp. OpenUI5 right from a XMLView.
<!-- see sap.ui.core.XMLTemplateProcessor -->
<Control binding="{
model: 'modelName',
path: '/context/path'
}">
<Control objectBindings="{
model: 'modelName',
path: '/context/path'
}">
@cschuff
cschuff / AutofocusControlOnViewShow
Created November 22, 2017 09:53
Autofocus a SAPUI5 control everytime a View is shown (if Router is used)
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function (Controller) {
"use strict";
return Controller.extend("ui5experts.controller.Autofocus", {
onInit: function() {
this.getRouter().attachRoutePatternMatched(this.onRoutePatternMatched, this);
this.byId("MyControl").addEventDelegate({
onAfterRendering: function () {
// do stuff
}
}, this.byId("MyControl"));
@cschuff
cschuff / karma.conf.js
Last active September 5, 2017 19:28
A simple karma.conf.js for SAPUI5 projects created with SAP Web IDE templates. Tests are run in Chrome (auto-installed) by default. Tests will be re-run on changes so this suites fine for Test-driven Development. Code coverage and test reports will be created. For CI do 'karma start --single-run --browsers ChromeHeadless'
// Setup ChromeHeadless
// see https://github.com/karma-runner/karma-chrome-launcher
const ChromiumRevision = require('puppeteer/package.json').puppeteer.chromium_revision;
const Downloader = require('puppeteer/utils/ChromiumDownloader');
const revisionInfo = Downloader.revisionInfo(Downloader.currentPlatform(), ChromiumRevision);
process.env.CHROME_BIN = revisionInfo.executablePath;
// karma.conf.js
@cschuff
cschuff / metadata.xml
Created September 5, 2017 15:07
Minimal metadata.xml to satisfy SAP Web IDE Template wizards...
<edmx:Edmx Version="1.0"
xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns:sap="http://www.sap.com/Protocols/SAPData">
<edmx:DataServices m:DataServiceVersion="2.0">
<Schema Namespace="UI_Testing" xml:lang="en"
xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityType Name="Travel" sap:content-version="1">
<Key>
<PropertyRef Name="WorkItemID"/>
@cschuff
cschuff / package.json
Last active February 19, 2018 10:54
Minimal Express.js server for local SAPUI5 development. Also works for SAP Web IDE projects. Only framework sources are proxied, no OData supported. Run with '$ npm start'.
{
"name": "ui5-experts-servergist",
"version": "1.0.0",
"description": "",
"main": "server.js",
"author": {
"name": "Christian Schuff",
"email": "christian.schuff@ui5experts.com",
"url": "http://www.ui5experts.com"
},