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 / SortComparatorCollection.js
Created February 24, 2017 13:26
Sort Comparators for sap.ui.model.Sorter
// ISO Date as string
function (a, b) {
var valA = a.split("T")[0];
var valB = b.split("T")[0];
if (valA < valB) return -1;
if (valA > valB) return 1;
return 0;
};
// string as number
@cschuff
cschuff / karma.conf.js
Last active March 15, 2017 09:27
A freshly generated karma.conf.js using 'qunit' and PhantomJS'. Generated using '$ karma init karma.conf.js'
// Karma configuration
// Generated on Wed Mar 08 2017 11:21:46 GMT+0100 (CET)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
@cschuff
cschuff / XMLViewWithFragment.view.xml
Created March 14, 2017 10:58
Usage of Fragments in SAPUI5 XMLViews
<core:View xmlns:core="sap.ui.core"
xmlns="sap.m"
controllerName="ui5experts.Root">
<core:Fragment fragmentName="ui5experts.fragment.Fragment" type="XML" />
</core:View>
@cschuff
cschuff / npm.sh
Last active March 20, 2017 08:33
npm
# show available versions of an npm package
npm show [PACKAGE_NAME] versions
@cschuff
cschuff / StopItControl.js
Created April 3, 2017 12:32
Stop OData Aggregation Bindings from heavy blinking
invalidate: function () {
var oBinding = this.getBinding("plannings");
// do not rerender during odate request is running since it causes heavy blinking
if (!oBinding || !oBinding.bPendingRequest) {
Control.prototype.invalidate.apply(this, arguments);
}
},
@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": "[email protected]",
"url": "http://www.ui5experts.com"
},
@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 / 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
this.byId("MyControl").addEventDelegate({
onAfterRendering: function () {
// do stuff
}
}, this.byId("MyControl"));
@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);