getOrgChart 'renderBoxContentEvent' (new 'renderEvent') not working on version 2.0.6 - getorgchart

I'm using getOrgChart for quite a while. With this new update I'm facing some problems. I used the event 'renderBoxContentEvent' (that now was renamed to 'renderEvent'), but now, this new function is never called. Follow the code snippet:
orgChart = new getOrgChart(peopleElement, {
theme: "annabel",
primaryFields: ["Area", "Nome"],
photoFields: ["Imagem"],
linkType: "M",
enableEdit: true,
enableDetailsView: false,
expandToLevel: 2,
renderEvent: renderBox,
renderBoxContentEvent:renderBox,
updatedEvent: updatedEvent,
dataSource: dsOriginalCopy,
});
function renderBox(sender, args) {
alert(1);
}
Any ideas?

Actually it is renamed to renderNodeEvent in version 2.0.7. Here is an example:
var orgchart = new getOrgChart(document.getElementById("people"), {
renderNodeEvent: renderNodeEvent,
dataSource: [{id: 1,parentId: null,Name: "Amber McKenzie"}, {id: 2,parentId: 1,Name: "Ava Field"}, {id: 3,parentId: 1,Name: "Evie Johnson"}]
});
function renderNodeEvent(sender, args) {
args.content[2] = args.content[2].replace("Amber McKenzie", "The name has been replaced");
}
See the documentation: http://www.getorgchart.com/Documentation#renderNodeEvent
and download the latest version:
http://www.getorgchart.com/Download

Related

Is there any way to set a suffix into a env variable with convict?

I am trying to refactor old code to manage env variables to convict, the problem is that I have the following case:
Old code
{
indexAlias: process.env.ES_INDEX ? `${process.env.ES_INDEX}_sw` : "",
}
Convict code
esIndex: {
doc: "",
format: String,
env: "ES_INDEX",
default: "",
}
The problem here is there are other ES_INDEX references with other suffixes and a lot of cross dependencies with that env variable in CI/CD applications, so instead of changing that env variable in all infrastructure or creating a lot, one for each suffix, I would like to know if there is any way of setting a suffix to convict?
I solved using addFormat like a new type
var convict = require('convict');
convict.addFormat({
name: 'sw-suffix',
validate: function(val) {
if (!(val instanceof "string")) {
throw new Error('must be a string');
}
},
coerce: (val) => {
return `${val}_sf`;
}
});
var config = convict({
space_used: {
format: 'sw-suffix',
default: "aaa"
}
});
console.log(config.get('space_used')) // aaa_sw

Include: dependency injection CodeceptJS/Puppeteer - Missing something?

I am clearly missing something related to dependency injection with CodeceptJS and Puppeteer. I am attempting to follow the docs but not yet successful.
Goal: Create a page object class, access the methods in that page object class from my test scenarios.
Simple test case
Feature('Common logon/logoff scenarios');
Scenario.only('Test drawer class', (I, loginAs, menu) => {
I.amOnPage('/login');
loginAs('admin');
menu.dashboard();
});
Include section from my codeceptjs.config.js file
include: {
I: "./steps_file.js",
menu: "./src/fragments/menu.js"
},
Menu page object class (menu.js)
const { I } = inject();
module.exports = {
// Navigation drawer locators
item: {
dashboard: 'a[href="#/"]',
admin: 'li[id="resources.admin.name"]',
permissions: 'a[href="#/user-claims"]',
sites: 'a[href="#/site"]',
reportTemplates: 'a[href="#/reporttemplates"]',
stations: 'a[href="#/station"]',
supervisor: 'li[id="resources.supervisor.name"]',
people: 'a[href="#/people"]',
supervisorPressPallets: 'a[href="#/presspalletbuilder"]',
stationIdentify: 'a[href="#/stationadopt"]',
operator: 'li[id="resources.operator.name"]',
operatorPressPallets: 'a[href="resources.operator.name"]'
},
// Methods to access nav drawer menu items
dashboard() {
I.click(this.item.dashboard);
},
admin() {
I.click(this.item.admin);
},
permissions() {
I.click(this.item.permissions);
},
sites() {
I.click(this.item.sites);
},
reportTemplates() {
I.click(this.item.reportTemplates);
},
stations() {
I.click(this.item.stations);
},
supervisor() {
I.click(this.item.supervisor);
},
people() {
I.click(this.item.people);
},
supervisorPressPallets() {
I.click(this.item.supervisorPressPallets);
},
stationIdentify() {
I.click(this.item.stationIdentify);
},
operator() {
I.click(this.item.operator);
},
operatorPressPallets() {
I.click(this.item.operatorPressPallets);
}
}
When I attempt to run the test, I get the following error
1) Common logon/logoff scenarios
Test drawer class:
Cannot read property 'react' of undefined
Any assistance with what I am missing here would be greatly appreciated.
Thanks, all
Bob
Turns out the code I had was correct and this ended up being an issue with my editor not handling code completion well so the methods of interest were not displaying as I had expected them to.

How to make separate report for different specification files in protractor?

How can we make separate reports for different specification files in protractor?
multiCapabilities: [{
'browserName': 'chrome'
}, {
'browserName': 'firefox'
}
{
'browserName': 'internet explorer'
}],
framework: 'jasmine',
specs: ['TC_2.js','TC_3.js'],
Currently my code will generate HTML report for "chrome" execution in first iteration.When it go next iteration,it will generate report for "FF".In 3rd iteration it will generate report for "IE".However at the end I am getting last iteration(i.e 3rd )internet explorer HTML report at base location.Because this last iteration replacing the report of previous iterations.
Is there a way to get all 3 reports?(i.e Chrome,FF and IE reports)
protractor-html-screenshot-reporter is the report I am using.
Following is my code:
onPrepare: function() {
beforeEach(function() {
browser.driver.manage().window().setSize(1280, 1024);
});
jasmine.getEnv().addReporter(new HtmlReporter({
baseDirectory: 'D:/Manoj/TestReport3/',
docTitle: 'Test Case Execution Details',
docName: 'BYTestReport.html',
//Meta builder
metaDataBuilder: function(spec, descriptions, results, capabilities){
var metaData = {
description: descriptions.join('|'),
passed: results.passed(),
os: 'Windows 7',
browser: {
name: capabilities.caps_.browserName
, version: capabilities.caps_.version
}
};
if(results.items_.length > 0) {
var result = results.items_[0];
metaData.message = result.message;
metaData.trace = result.trace.stack;
}
return metaData;
} // Meta Builder ends
}));
},
Yes, I use browserName as folder name for html report, and jsons, and pngs:
Inside onPrepare: function(){
browser.getCapabilities().then(function (cap) {
console.log(cap);
browser.browserName = cap.caps_.browserName;
jasmine.getEnv().addReporter(new HtmlReporter({
baseDirectory: 'target/'+browser.browserName+'/angular-test-result/',
takeScreenShotsOnlyForFailedSpecs: true,
preserveDirectory: false
}));
});
and remove addReporter from where you already have it
Your code updated to protractor-html-screenshot-reporter:
var HtmlReporter = require('protractor-html-screenshot-reporter');
onPrepare: function() {
browser.driver.manage().window().setSize(1280, 1024);
browser.getCapabilities().then(function (cap) {
console.log(cap);
browser.browserName = cap.caps_.browserName;
jasmine.getEnv().addReporter(new HtmlReporter({
baseDirectory: 'target/'+browser.browserName+'/angular-test-result/',
takeScreenShotsOnlyForFailedSpecs: true,
preserveDirectory: false
}));
});
}
BTW you have to install reporter: npm install protractor-html-screenshot-reporter --save-dev
You can create different protractor config files for specific specs and trigger those specific e2e suits with different command specifying in package.json passing the config file as parameter.
ex: "specifice2e": "\"ng e2e --protractorConfig=e2e\specificprotractor.conf.js "
And in config file you can mention the folder name where you want to generate seperate report.

Famo.us RenderController not working under SequentialLayout?

I have added a common Surface and a Scrollview (actually a FlexScrollView) to a SequentialLayout and then added the layout to my View as the following code shows:
function _createCameraView() {
var layoutViews = [];
this.cameraView = new View({
size: [undefined, this.options.footerSize]
});
var layout = new SequentialLayout({
size: [undefined, this.options.footerSize],
direction: Utility.Direction.Y
});
var backgroundSurface = new Surface({
size: [undefined, 120],
content: 'some content',
classes : ['photo-guide-content'],
properties: {
backgroundColor: 'transparent',
zIndex: 4
}
});
// detail list
var detailsList = new FlexScrollView({
layout: ListLayout,
direction: Utility.Direction.X, // set direction to horizontal
paginated: true,
//autoPipeEvents: true,
useContainer: true,
container : {
size: [undefined, 60],
properties : {
'z-index' : 5,
}
}
});
layoutViews.push(backgroundSurface);
layoutViews.push(detailsList);
layout.sequenceFrom(layoutViews);
this.cameraView.add(alignModifier).add(layout);
}
Then I've added a RenderController on another view and I'm using it to display my cameraView like this:
function _selectCamera() {
if (!this.cameraView) {
_createCameraView.call(this);
}
this.footerRender.hide(this.mapView);
this.footerRender.show(this.cameraView);
}
I know I don't need to call the hide method from the render on the function above, just the show method and it should swap the views with a smooth opacity transition, which is defined by default. Although when using this Sequential Layout I'm not getting this effect. I know it has to do with this layout because I've tried to switch the layout to a FlexibleLayout and a GridLayout, and it works fine with these two. So, my question is, why doesn't work with the SequentialLayout? I've also noticed it has a method called setOutputFunction(outputFunction), is there a way to use it so the layout uses the opacity returned from the RenderController or how can it be fixed some other way?
Try adding a getSize method to your view.
Something like this:
this.cameraView.getSize = function() {
return [undefined, undefined];
};

YUI, instantiable module that is not a widget?

If I want a module that is instantiable, let say, a module that handles storing preferences in a subcookies, and i want the main cookie to be configurable, but i don't want it to be a widget... what patterns should i use with YUI?
the end code should be something:
Y.use('my-pref-manager', function(Y){
var A = Y.my-pref-manager.prefStore('A"),
B = Y.my-pref-manager.prefStore('B");
// A and B are now loaded with the contents of cookies A and B, if they exist
A.set('xy', 123 );
});
So far i either found patterns that create widgets within my-module or i have to use methods directly in my-method which will be globals and lack initializers, etc.
There is a bunch of ways of doing this. You could do it using Y.Base.create, like below. The code might not be production ready, or even working properly, but hopefully it answers how you can create a module without it being a Widget.
The code below creates a module that extends Y.Base. This let us use Attributes and other cool things. Check the doc for Y.Base.
YUI.add('my-pref-manager', function (Y) {
var PrefManager = Y.Base.create('myPrefManager', Y.Base, [], {
initializer: function () {
this.after('prefsChange', this.changePref);
},
changePref: function (e) {
Y.Cookie.setSub(this.get('prefStore'), e.subAttrName, this.get(e.subAttrName));
},
setPref: function (name, val) {
this.set('prefs.'+name, val);
},
getPref: function (name) {
return this.get('prefs.'+name);
}
}, {
ATTRS: {
prefStore: {
value: null,
setter: function (val) {
return Y.Cookie.set(val, val);
}
},
prefs: {
value: {}
}
}
});
Y.namespace('My').PrefManager = PrefManager;
}, '0.0.1', {
requires: ['base', 'cookie']
});
YUI().use('my-pref-manager', function (Y) {
var A = new Y.My.PrefManager({prefStore: 'userPrefs'}),
B = new Y.My.PrefManager({prefStore: 'displayPrefs'});
A.setPref('x', 3);
A.setPref('y', 54);
B.setPref('tty', 7);
console.log(A.getPref('x')); // 3
});
Try it out: http://jsfiddle.net/B62nu/

Resources