How to use getInvisibleElements method in Testcafe

Best JavaScript code snippet using testcafe

ActionExtractor-dbg.js

Source:ActionExtractor-dbg.js Github

copy

Full Screen

1/*!2 * OpenUI53 * (c) Copyright 2009-2021 SAP SE or an SAP affiliate company.4 * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.5 */6sap.ui.define([7 "sap/base/util/restricted/_difference",8 "sap/base/util/merge",9 "sap/base/Log",10 "sap/ui/core/util/reflection/JsControlTreeModifier",11 "sap/ui/dt/ElementUtil",12 "sap/ui/dt/OverlayRegistry",13 "sap/ui/fl/apply/api/DelegateMediatorAPI",14 "sap/ui/rta/plugin/additionalElements/AdditionalElementsUtils",15 "sap/ui/rta/Utils"16], function(17 difference,18 merge,19 Log,20 JsControlTreeModifier,21 ElementUtil,22 OverlayRegistry,23 DelegateMediatorAPI,24 AdditionalElementsUtils,25 Utils26) {27 "use strict";28 /**29 * Helper object that collects and returns the data related to the different actions30 * handled by the AdditionalElements Plugin (Reveal, Add Via Delegate, Add Custom)31 *32 * @author SAP SE33 * @version 1.96.434 * @private35 * @since 1.9436 * @experimental Since 1.94. This class is experimental and provides only limited functionality. Also the API might be changed in future.37 */38 var ActionExtractor = {};39 function loadKnownDefaultDelegateLibraries() {40 var aLoadLibraryPromises = [];41 var aRequiredLibraries = DelegateMediatorAPI.getKnownDefaultDelegateLibraries();42 aRequiredLibraries.forEach(function(sLibrary) {43 var oLoadLibraryPromise = sap.ui.getCore().loadLibrary(sLibrary, { async: true })44 .then(function() {45 return Promise.resolve(sLibrary);46 })47 .catch(function(vError) {48 Log.warning("Required library not available: ", vError);49 // Ignore the error here as the default delegate might not be required50 return Promise.resolve();51 });52 aLoadLibraryPromises.push(oLoadLibraryPromise);53 });54 return Promise.all(aLoadLibraryPromises);55 }56 function getAddViaDelegateActionData(mAction, oDesignTimeMetadata, oPlugin) {57 return oPlugin.hasChangeHandler(mAction.changeType, mAction.element)58 .then(function (bHasChangeHandler) {59 if (bHasChangeHandler) {60 return {61 aggregationName: mAction.aggregation,62 addPropertyActionData: {63 designTimeMetadata: oDesignTimeMetadata,64 action: mAction,65 delegateInfo: {66 payload: mAction.delegateInfo.payload || {},67 delegate: mAction.delegateInfo.instance,68 modelType: mAction.delegateInfo.modelType,69 requiredLibraries: mAction.delegateInfo.requiredLibraries70 }71 }72 };73 }74 return undefined;75 });76 }77 function checkInvalidAddActions(bSibling, oSourceElementOverlay, oPlugin) {78 var mParents = AdditionalElementsUtils.getParents(bSibling, oSourceElementOverlay, oPlugin);79 var oDesignTimeMetadata = mParents.parentOverlay && mParents.parentOverlay.getDesignTimeMetadata();80 var aActions = oDesignTimeMetadata ? oDesignTimeMetadata.getActionDataFromAggregations("addODataProperty", mParents.parent) : [];81 if (aActions.length > 0) {82 Log.error("Outdated addODataProperty action in designtime metadata in "83 + oDesignTimeMetadata.getData().designtimeModule84 + " or propagated or via instance specific designtime metadata.");85 }86 }87 function getInvisibleElements (oParentOverlay, sAggregationName, oPlugin) {88 var oParentElement = oParentOverlay.getElement();89 if (!oParentElement) {90 return [];91 }92 // Returns a list of all invisible elements belonging to an aggregation including the aggregation name93 var aInvisibleElements = ElementUtil.getAggregation(oParentElement, sAggregationName, oPlugin).filter(function(oControl) {94 var oOverlay = OverlayRegistry.getOverlay(oControl);95 if (!oPlugin.hasStableId(oOverlay)) {96 return false;97 }98 var oRelevantContainer = oParentOverlay.getRelevantContainer(true);99 var oRelevantContainerOverlay = OverlayRegistry.getOverlay(oRelevantContainer);100 var oOverlayToCheck = oParentOverlay;101 var bAnyParentInvisible = false;102 // check all the parents until the relevantContainerOverlay for invisibility103 do {104 bAnyParentInvisible = !oOverlayToCheck.getElementVisibility();105 if (bAnyParentInvisible) {106 break;107 }108 if (oOverlayToCheck === oRelevantContainerOverlay) {109 break;110 } else {111 oOverlayToCheck = oOverlayToCheck.getParentElementOverlay();112 }113 } while (oOverlayToCheck);114 if (bAnyParentInvisible) {115 return true;116 }117 return oOverlay.getElementVisibility() === false;118 }, this);119 return aInvisibleElements.map(function(oInvisibleElement) {120 return {121 element: oInvisibleElement,122 sourceAggregation: sAggregationName123 };124 });125 }126 function defaultGetAggregationName(oParent, oChild) {127 return oChild.sParentAggregationName;128 }129 function isValidAction(oCheckElementOverlay, mParents, mAction, oPlugin) {130 var bValidAction = mAction.changeType && oPlugin.hasStableId(oCheckElementOverlay);131 if (bValidAction && oCheckElementOverlay !== mParents.relevantContainerOverlay) {132 //relevant container is needed for some changes, so it must have a stable ID133 bValidAction = oPlugin.hasStableId(mParents.relevantContainerOverlay);134 }135 return bValidAction;136 }137 function filterValidAddPropertyActions(aActions, mParents, oPlugin, aDefaultDelegateLibraries) {138 function fnFilterActions(aFilteredActions, mAction) {139 var oCheckElement = mAction.changeOnRelevantContainer ? mParents.relevantContainer : mParents.parent;140 var oCheckElementOverlay = OverlayRegistry.getOverlay(oCheckElement);141 var bValidAction = isValidAction(oCheckElementOverlay, mParents, mAction, oPlugin);142 if (bValidAction) {143 mAction.element = oCheckElement;144 return DelegateMediatorAPI.getDelegateForControl({145 control: mParents.relevantContainer, //delegate will always be added on the relevant container146 modifier: JsControlTreeModifier,147 supportsDefault: mAction.supportsDefaultDelegate148 })149 .then(function(mDelegateInfo) {150 if (mDelegateInfo && mDelegateInfo.names && mDelegateInfo.names.length) {151 var aRequiredLibraries = DelegateMediatorAPI.getRequiredLibrariesForDefaultDelegate({152 delegateName: mDelegateInfo.names,153 control: mParents.relevantContainer154 });155 // Check if all required libraries were successfully loaded156 if (157 difference(158 aRequiredLibraries,159 aDefaultDelegateLibraries.filter(Boolean)160 ).length === 0161 ) {162 mAction.delegateInfo = mDelegateInfo;163 aFilteredActions.push(mAction);164 }165 }166 return aFilteredActions;167 });168 }169 return aFilteredActions;170 }171 return aActions.reduce(function (oPreviousActionsPromise, mAction) {172 return oPreviousActionsPromise173 .then(function(aFilteredActions) {174 return fnFilterActions(aFilteredActions, mAction);175 });176 }, Promise.resolve([]));177 }178 // Return all elements that can be made visible in each aggregation (including elements from other aggregations)179 function getRevealActionFromAggregations(aParents, _mReveal, sAggregationName, aAggregationNames, oPlugin) {180 var aInvisibleElements = aParents.reduce(function(aInvisibleChildren, oParentOverlay) {181 var aInvisibleChildrenPerAggregation = [];182 aAggregationNames.forEach(function(sAggregation) {183 aInvisibleChildrenPerAggregation = aInvisibleChildrenPerAggregation.concat(getInvisibleElements.call(this, oParentOverlay, sAggregation, oPlugin));184 }.bind(this), []);185 return oParentOverlay ? aInvisibleChildren.concat(aInvisibleChildrenPerAggregation) : aInvisibleChildren;186 }.bind(this), []);187 var oInitialRevealObject = {188 elements: [],189 controlTypeNames: []190 };191 var mRevealPromise = aInvisibleElements.reduce(function(oPreviousPromise, mInvisibleElement) {192 return oPreviousPromise.then(function(mReveal) {193 return checkAndEnrichReveal(mReveal, mInvisibleElement, oPlugin, sAggregationName);194 });195 }, Promise.resolve(oInitialRevealObject));196 return mRevealPromise.then(function(mReveal) {197 if (mReveal.elements.length > 0) {198 _mReveal[sAggregationName] = {199 reveal: mReveal200 };201 }202 return _mReveal;203 });204 }205 function checkAndEnrichReveal(mReveal, mInvisibleElement, oPlugin, sTargetAggregation) {206 return Promise.resolve().then(function() {207 var oInvisibleElement = mInvisibleElement.element;208 var oDesignTimeMetadata;209 var mRevealAction;210 var bRevealEnabled = false;211 var oHasChangeHandlerPromise = Promise.resolve();212 var sSourceAggregation = mInvisibleElement.sourceAggregation;213 var oOverlay = OverlayRegistry.getOverlay(oInvisibleElement);214 if (oOverlay) {215 oDesignTimeMetadata = oOverlay.getDesignTimeMetadata();216 mRevealAction = oDesignTimeMetadata && oDesignTimeMetadata.getAction("reveal", oInvisibleElement);217 if (mRevealAction && mRevealAction.changeType) {218 var oRevealSelector = oInvisibleElement;219 if (mRevealAction.changeOnRelevantContainer) {220 oRevealSelector = oOverlay.getRelevantContainer();221 }222 oHasChangeHandlerPromise = oPlugin.hasChangeHandler(mRevealAction.changeType, oRevealSelector).then(function(bHasChangeHandler) {223 var mParents = AdditionalElementsUtils.getParents(true, oOverlay, oPlugin);224 if (bHasChangeHandler) {225 if (mRevealAction.changeOnRelevantContainer) {226 //we have the child overlay, so we need the parents227 bRevealEnabled = oPlugin.hasStableId(mParents.relevantContainerOverlay)228 && oPlugin.hasStableId(mParents.parentOverlay);229 } else {230 bRevealEnabled = true;231 }232 if (!mRevealAction.getAggregationName) {233 mRevealAction.getAggregationName = defaultGetAggregationName;234 }235 // Check if the invisible element can be moved to the target aggregation236 if (bRevealEnabled && (sSourceAggregation !== sTargetAggregation)) {237 var oAggregationOverlay = mParents.parentOverlay.getAggregationOverlay(sTargetAggregation);238 return Utils.checkTargetZone(oAggregationOverlay, oOverlay, oPlugin);239 }240 }241 return bRevealEnabled;242 });243 }244 }245 return oHasChangeHandlerPromise.then(function(bIncludeReveal) {246 if (bIncludeReveal) {247 mReveal.elements.push({248 element: oInvisibleElement,249 designTimeMetadata: oDesignTimeMetadata,250 action: mRevealAction,251 sourceAggregation: sSourceAggregation,252 targetAggregation: sTargetAggregation253 });254 var mName = oDesignTimeMetadata.getName(oInvisibleElement);255 if (mName) {256 mReveal.controlTypeNames.push(mName);257 }258 }259 return mReveal;260 });261 });262 }263 /**264 * Calculate a structure with all "add/reveal/custom" action relevant data collected per aggregation:265 * <pre>266 * {267 * <aggregationName> : {268 * addViaDelegate : {269 * designTimeMetadata : <sap.ui.dt.ElementDesignTimeMetadata of parent>,270 * action : <add.delegate action section from designTimeMetadata>271 * },272 * reveal : {273 * elements : [{274 * element : <invisible element>,275 * designTimeMetadata : <sap.ui.dt.ElementDesignTimeMetadata of invisible element>,276 * action : <reveal action section from designTimeMetadata>,277 * sourceAggregation: <aggregation where this element is currently located>278 * }],279 * controlTypeNames : string[] <all controlTypeNames collected via designTimeMetadata>280 * },281 * addViaCustom : {282 * designTimeMetadata : <sap.ui.dt.ElementDesignTimeMetadata of parent>,283 * action : <add.custom action section from designTimeMetadata>284 * items : <add.custom action's array of items from the getItems() function>285 * }286 * },287 * <aggregationName2> : ...288 * }289 * </pre>290 *291 * @param {boolean} bSibling - Indicates if the elements should be added as sibling (true) or child (false) to the overlay292 * @param {sap.ui.dt.ElementOverlay} oSourceElementOverlay - Elements will be added in relation (sibling/parent) to this overlay293 * @param {sap.ui.rta.plugin.additionalElements.AdditionalElementsPlugin} oPlugin - Instance of the AdditionalElementsPlugin294 * @param {boolean} [bInvalidate] - Option to prevent cached actions to be returned295 *296 * @return {Promise} Resolving to a structure with all "add/reveal/custom" action relevant data collected297 */298 ActionExtractor.getActions = function(bSibling, oSourceElementOverlay, oPlugin, bInvalidate) {299 var sSiblingOrChild = bSibling ? "asSibling" : "asChild";300 if (!bInvalidate && oSourceElementOverlay._mAddActions) {301 return Promise.resolve(oSourceElementOverlay._mAddActions[sSiblingOrChild]);302 }303 var oRevealActionsPromise = this._getRevealActions(bSibling, oSourceElementOverlay, oPlugin);304 var oAddPropertyActionsPromise = this._getAddViaDelegateActions(bSibling, oSourceElementOverlay, oPlugin);305 var oCustomAddActionsPromise = this._getCustomAddActions(bSibling, oSourceElementOverlay, oPlugin);306 return Promise.all([307 oRevealActionsPromise,308 oAddPropertyActionsPromise,309 oCustomAddActionsPromise,310 checkInvalidAddActions(bSibling, oSourceElementOverlay, oPlugin)311 ]).then(function(aAllActions) {312 //join and condense all action data313 var mAllActions = merge(aAllActions[0], aAllActions[1], aAllActions[2]);314 oSourceElementOverlay._mAddActions = oSourceElementOverlay._mAddActions || {asSibling: {}, asChild: {}};315 oSourceElementOverlay._mAddActions[sSiblingOrChild] = mAllActions;316 return mAllActions;317 });318 };319 /**320 * Returns the already calculated actions of an Overlay, or undefined if no actions available321 * @param {boolean} bSibling - Indicates if the elements should be added as sibling (true) or child (false) to the overlay322 * @param {sap.ui.dt.ElementOverlay} oOverlay - Elements will be added in relation (sibling/parent) to this overlay323 * @returns {object/undefined} - Object with all "add/reveal/custom" action relevant data collected or undefined if no actions available324 */325 ActionExtractor.getActionsOrUndef = function(bSibling, oOverlay) {326 var sSiblingOrChild = bSibling ? "asSibling" : "asChild";327 return oOverlay._mAddActions && oOverlay._mAddActions[sSiblingOrChild];328 };329 /**330 * Returns the Reveal actions data (parameters + elements) for an Overlay331 * @param {boolean} bSibling - If source element overlay should be sibling or parent to the newly added fields332 * @param {sap.ui.dt.ElementOverlay} oSourceElementOverlay - Overlay where the action is triggered333 * @param {sap.ui.rta.plugin.additionalElements.AdditionalElementsPlugin} oPlugin - Instance of the AdditionalElements plugin334 *335 * @returns {Promise<object>} Reveal action data336 */337 ActionExtractor._getRevealActions = function(bSibling, oSourceElementOverlay, oPlugin) {338 var mParents = AdditionalElementsUtils.getParents(bSibling, oSourceElementOverlay, oPlugin);339 var aParents = [mParents.parentOverlay];340 if (mParents.relevantContainer !== mParents.parent) {341 aParents = ElementUtil.findAllSiblingsInContainer(mParents.parent, mParents.relevantContainer).map(function(oParent) {342 return OverlayRegistry.getOverlay(oParent);343 }).filter(function (oOverlay) {344 return oOverlay;345 });346 }347 var aAggregationNames = [];348 if (mParents.parentOverlay) {349 aAggregationNames = mParents.parentOverlay.getAggregationOverlays().filter(function(oAggregationOverlay) {350 return !oAggregationOverlay.getDesignTimeMetadata().isIgnored(mParents.parent);351 }).map(function(oAggregationOverlay) {352 return oAggregationOverlay.getAggregationName();353 });354 return aAggregationNames.reduce(function(oPreviousPromise, sAggregationName) {355 return oPreviousPromise.then(function(mReveal) {356 return getRevealActionFromAggregations(aParents, mReveal, sAggregationName, aAggregationNames, oPlugin);357 });358 }, Promise.resolve({}));359 }360 return Promise.resolve({});361 };362 /**363 * Return the AddViaDelegate action data (parameters + elements) for an Overlay.364 * @param {boolean} bSibling - If source element overlay should be sibling or parent to the newly added fields365 * @param {sap.ui.dt.ElementOverlay} oSourceElementOverlay - Overlay where the action is triggered366 * @param {sap.ui.rta.plugin.additionalElements.AdditionalElementsPlugin} oPlugin - Instance of the AdditionalElementsPlugin367 *368 * @returns {Promise<object>} AddViaDelegate action data369 */370 ActionExtractor._getAddViaDelegateActions = function(bSibling, oSourceElementOverlay, oPlugin) {371 var mParents = AdditionalElementsUtils.getParents(bSibling, oSourceElementOverlay, oPlugin);372 var oDesignTimeMetadata = mParents.parentOverlay && mParents.parentOverlay.getDesignTimeMetadata();373 return Promise.resolve()374 .then(function() {375 var aActions = oDesignTimeMetadata ? oDesignTimeMetadata.getActionDataFromAggregations("add", mParents.parent, undefined, "delegate") : [];376 if (aActions.length) {377 return loadKnownDefaultDelegateLibraries()378 .then(filterValidAddPropertyActions.bind(this, aActions, mParents, oPlugin));379 }380 return [];381 }.bind(this))382 .then(function(aActions) {383 return aActions.reduce(function (oPreviousPromise, oAction) {384 return oPreviousPromise385 .then(function (oReturn) {386 return getAddViaDelegateActionData.call(this, oAction, oDesignTimeMetadata, oPlugin)387 .then(function (mAction) {388 if (mAction) {389 mAction.addPropertyActionData.relevantContainer = mParents.relevantContainer;390 if (!oReturn[mAction.aggregationName]) {391 oReturn[mAction.aggregationName] = {};392 }393 oReturn[mAction.aggregationName].addViaDelegate = mAction.addPropertyActionData;394 }395 return oReturn;396 });397 }.bind(this));398 }.bind(this), Promise.resolve({}));399 }.bind(this));400 };401 /**402 * Return the CustomAdd action data (parameters + elements) for an Overlay.403 * @param {boolean} bSibling - If source element overlay should be sibling or parent to the newly added fields404 * @param {sap.ui.dt.ElementOverlay} oOverlay - Overlay where the action is triggered405 * @param {sap.ui.rta.plugin.additionalElements.AdditionalElementsPlugin} oPlugin - Instance of the AdditionalElementsPlugin406 *407 * @returns {Promise<object>} CustomAdd action data408 */409 ActionExtractor._getCustomAddActions = function(bSibling, oOverlay, oPlugin) {410 var mParents = AdditionalElementsUtils.getParents(bSibling, oOverlay, oPlugin);411 var oDesignTimeMetadata = mParents.parentOverlay && mParents.parentOverlay.getDesignTimeMetadata();412 var aActions = oDesignTimeMetadata && oDesignTimeMetadata.getActionDataFromAggregations("add", mParents.parent, undefined, "custom") || [];413 function getAction(mAction, oCheckElement) {414 var aItems = [];415 return Promise.resolve()416 .then(function () {417 if (mAction && typeof mAction.getItems === "function") {418 var oCheckElementOverlay = OverlayRegistry.getOverlay(oCheckElement);419 if (oPlugin.hasStableId(oCheckElementOverlay)) {420 return mAction.getItems(oCheckElement);421 }422 }423 return aItems;424 })425 .then(function (aItemsFromAction) {426 aItems = aItemsFromAction || [];427 var aChangeHandlerPromises = aItems.reduce(function (aPromises, oItem) {428 // adjust relevant container429 if (oItem.changeSpecificData.changeOnRelevantContainer) {430 oCheckElement = mParents.relevantContainer;431 }432 if (oItem.changeSpecificData.changeType) {433 aPromises.push(oPlugin.hasChangeHandler(oItem.changeSpecificData.changeType, oCheckElement));434 }435 return aPromises;436 }, []);437 return Promise.all(aChangeHandlerPromises);438 })439 .then(function (aHasChangeHandlerForCustomItems) {440 if (aHasChangeHandlerForCustomItems.indexOf(false) === -1) {441 return {442 aggregationName: mAction.aggregation,443 addViaCustom: {444 designTimeMetadata: oDesignTimeMetadata,445 action: mAction,446 items: aItems447 }448 };449 }450 return undefined;451 });452 }453 var oCheckElement = mParents.parent;454 return aActions.reduce(function(oPreviousPromise, oAction) {455 return oPreviousPromise.then(function(oReturn) {456 return getAction.call(this, oAction, oCheckElement).then(function(mAction) {457 if (mAction) {458 oReturn[mAction.aggregationName] = {459 addViaCustom: mAction.addViaCustom460 };461 }462 return oReturn;463 });464 }.bind(this));465 }.bind(this), Promise.resolve({}));466 };467 return ActionExtractor;...

Full Screen

Full Screen

ActionExtractor.js

Source:ActionExtractor.js Github

copy

Full Screen

1/*!2 * ${copyright}3 */4sap.ui.define([5 "sap/base/util/restricted/_difference",6 "sap/base/util/merge",7 "sap/base/Log",8 "sap/ui/core/util/reflection/JsControlTreeModifier",9 "sap/ui/dt/ElementUtil",10 "sap/ui/dt/OverlayRegistry",11 "sap/ui/fl/apply/api/DelegateMediatorAPI",12 "sap/ui/rta/plugin/additionalElements/AdditionalElementsUtils",13 "sap/ui/rta/Utils"14], function(15 difference,16 merge,17 Log,18 JsControlTreeModifier,19 ElementUtil,20 OverlayRegistry,21 DelegateMediatorAPI,22 AdditionalElementsUtils,23 Utils24) {25 "use strict";26 /**27 * Helper object that collects and returns the data related to the different actions28 * handled by the AdditionalElements Plugin (Reveal, Add Via Delegate, Add Custom)29 *30 * @author SAP SE31 * @version ${version}32 * @private33 * @since 1.9434 * @experimental Since 1.94. This class is experimental and provides only limited functionality. Also the API might be changed in future.35 */36 var ActionExtractor = {};37 function loadKnownDefaultDelegateLibraries() {38 var aLoadLibraryPromises = [];39 var aRequiredLibraries = DelegateMediatorAPI.getKnownDefaultDelegateLibraries();40 aRequiredLibraries.forEach(function(sLibrary) {41 var oLoadLibraryPromise = sap.ui.getCore().loadLibrary(sLibrary, { async: true })42 .then(function() {43 return Promise.resolve(sLibrary);44 })45 .catch(function(vError) {46 Log.warning("Required library not available: ", vError);47 // Ignore the error here as the default delegate might not be required48 return Promise.resolve();49 });50 aLoadLibraryPromises.push(oLoadLibraryPromise);51 });52 return Promise.all(aLoadLibraryPromises);53 }54 function getAddViaDelegateActionData(mAction, oDesignTimeMetadata, oPlugin) {55 return oPlugin.hasChangeHandler(mAction.changeType, mAction.element)56 .then(function (bHasChangeHandler) {57 if (bHasChangeHandler) {58 return {59 aggregationName: mAction.aggregation,60 addPropertyActionData: {61 designTimeMetadata: oDesignTimeMetadata,62 action: mAction,63 delegateInfo: {64 payload: mAction.delegateInfo.payload || {},65 delegate: mAction.delegateInfo.instance,66 modelType: mAction.delegateInfo.modelType,67 requiredLibraries: mAction.delegateInfo.requiredLibraries68 }69 }70 };71 }72 return undefined;73 });74 }75 function checkInvalidAddActions(bSibling, oSourceElementOverlay, oPlugin) {76 var mParents = AdditionalElementsUtils.getParents(bSibling, oSourceElementOverlay, oPlugin);77 var oDesignTimeMetadata = mParents.parentOverlay && mParents.parentOverlay.getDesignTimeMetadata();78 var aAddODataPropertyActions = oDesignTimeMetadata ? oDesignTimeMetadata.getActionDataFromAggregations("addODataProperty", mParents.parent) : [];79 if (aAddODataPropertyActions.length > 0) {80 Log.error("Outdated addODataProperty action in designtime metadata in "81 + oDesignTimeMetadata.getData().designtimeModule82 + " or propagated or via instance specific designtime metadata.");83 }84 var aAddActions = oDesignTimeMetadata ? oDesignTimeMetadata.getActionDataFromAggregations("add", mParents.parent) : [];85 aAddActions.forEach(function(mAddAction) {86 if (mAddAction["custom"]) {87 Log.error("Outdated custom add action in designtime metadata in "88 + oDesignTimeMetadata.getData().designtimeModule89 + " or propagated or via instance specific designtime metadata.");90 }91 });92 }93 function getInvisibleElements (oParentOverlay, sAggregationName, oPlugin) {94 var oParentElement = oParentOverlay.getElement();95 if (!oParentElement) {96 return [];97 }98 // Returns a list of all invisible elements belonging to an aggregation including the aggregation name99 var aInvisibleElements = ElementUtil.getAggregation(oParentElement, sAggregationName, oPlugin).filter(function(oControl) {100 var oOverlay = OverlayRegistry.getOverlay(oControl);101 if (!oPlugin.hasStableId(oOverlay)) {102 return false;103 }104 var oRelevantContainer = oParentOverlay.getRelevantContainer(true);105 var oRelevantContainerOverlay = OverlayRegistry.getOverlay(oRelevantContainer);106 var oOverlayToCheck = oParentOverlay;107 var bAnyParentInvisible = false;108 // check all the parents until the relevantContainerOverlay for invisibility109 do {110 bAnyParentInvisible = !oOverlayToCheck.getElementVisibility();111 if (bAnyParentInvisible) {112 break;113 }114 if (oOverlayToCheck === oRelevantContainerOverlay) {115 break;116 } else {117 oOverlayToCheck = oOverlayToCheck.getParentElementOverlay();118 }119 } while (oOverlayToCheck);120 if (bAnyParentInvisible) {121 return true;122 }123 return oOverlay.getElementVisibility() === false;124 }, this);125 return aInvisibleElements.map(function(oInvisibleElement) {126 return {127 element: oInvisibleElement,128 sourceAggregation: sAggregationName129 };130 });131 }132 function defaultGetAggregationName(oParent, oChild) {133 return oChild.sParentAggregationName;134 }135 function isValidAction(oCheckElementOverlay, mParents, mAction, oPlugin) {136 var bValidAction = mAction.changeType && oPlugin.hasStableId(oCheckElementOverlay);137 if (bValidAction && oCheckElementOverlay !== mParents.relevantContainerOverlay) {138 //relevant container is needed for some changes, so it must have a stable ID139 bValidAction = oPlugin.hasStableId(mParents.relevantContainerOverlay);140 }141 return bValidAction;142 }143 function filterValidAddPropertyActions(aActions, mParents, oPlugin, aDefaultDelegateLibraries) {144 function fnFilterActions(aFilteredActions, mAction) {145 var oCheckElement = mAction.changeOnRelevantContainer ? mParents.relevantContainer : mParents.parent;146 var oCheckElementOverlay = OverlayRegistry.getOverlay(oCheckElement);147 var bValidAction = isValidAction(oCheckElementOverlay, mParents, mAction, oPlugin);148 if (bValidAction) {149 mAction.element = oCheckElement;150 return DelegateMediatorAPI.getDelegateForControl({151 control: mParents.relevantContainer, //delegate will always be added on the relevant container152 modifier: JsControlTreeModifier,153 supportsDefault: mAction.supportsDefaultDelegate154 })155 .then(function(mDelegateInfo) {156 if (mDelegateInfo && mDelegateInfo.names && mDelegateInfo.names.length) {157 var aRequiredLibraries = DelegateMediatorAPI.getRequiredLibrariesForDefaultDelegate({158 delegateName: mDelegateInfo.names,159 control: mParents.relevantContainer160 });161 // Check if all required libraries were successfully loaded162 if (163 difference(164 aRequiredLibraries,165 aDefaultDelegateLibraries.filter(Boolean)166 ).length === 0167 ) {168 mAction.delegateInfo = mDelegateInfo;169 aFilteredActions.push(mAction);170 }171 }172 return aFilteredActions;173 });174 }175 return aFilteredActions;176 }177 return aActions.reduce(function (oPreviousActionsPromise, mAction) {178 return oPreviousActionsPromise179 .then(function(aFilteredActions) {180 return fnFilterActions(aFilteredActions, mAction);181 });182 }, Promise.resolve([]));183 }184 // Return all elements that can be made visible in each aggregation (including elements from other aggregations)185 function getRevealActionFromAggregations(aParents, _mReveal, sAggregationName, aAggregationNames, oPlugin) {186 var aInvisibleElements = aParents.reduce(function(aInvisibleChildren, oParentOverlay) {187 var aInvisibleChildrenPerAggregation = [];188 aAggregationNames.forEach(function(sAggregation) {189 aInvisibleChildrenPerAggregation = aInvisibleChildrenPerAggregation.concat(getInvisibleElements.call(this, oParentOverlay, sAggregation, oPlugin));190 }.bind(this), []);191 return oParentOverlay ? aInvisibleChildren.concat(aInvisibleChildrenPerAggregation) : aInvisibleChildren;192 }.bind(this), []);193 var oInitialRevealObject = {194 elements: [],195 controlTypeNames: []196 };197 var mRevealPromise = aInvisibleElements.reduce(function(oPreviousPromise, mInvisibleElement) {198 return oPreviousPromise.then(function(mReveal) {199 return checkAndEnrichReveal(mReveal, mInvisibleElement, oPlugin, sAggregationName);200 });201 }, Promise.resolve(oInitialRevealObject));202 return mRevealPromise.then(function(mReveal) {203 if (mReveal.elements.length > 0) {204 _mReveal[sAggregationName] = {205 reveal: mReveal206 };207 }208 return _mReveal;209 });210 }211 function checkAndEnrichReveal(mReveal, mInvisibleElement, oPlugin, sTargetAggregation) {212 var oInvisibleElement = mInvisibleElement.element;213 var oDesignTimeMetadata;214 var mRevealAction;215 var bRevealEnabled = false;216 var oHasChangeHandlerPromise = Promise.resolve(false);217 var sSourceAggregation = mInvisibleElement.sourceAggregation;218 var oOverlay = OverlayRegistry.getOverlay(oInvisibleElement);219 if (oOverlay) {220 oDesignTimeMetadata = oOverlay.getDesignTimeMetadata();221 mRevealAction = oDesignTimeMetadata && oDesignTimeMetadata.getAction("reveal", oInvisibleElement);222 if (mRevealAction && mRevealAction.changeType) {223 var oRevealSelector = oInvisibleElement;224 if (mRevealAction.changeOnRelevantContainer) {225 oRevealSelector = oOverlay.getRelevantContainer();226 }227 oHasChangeHandlerPromise = oPlugin.hasChangeHandler(mRevealAction.changeType, oRevealSelector).then(function(bHasChangeHandler) {228 // Element can be made invalid while the check is running (e.g. destroyed during undo of split)229 if (ElementUtil.isElementValid(oInvisibleElement)) {230 var mParents = AdditionalElementsUtils.getParents(true, oOverlay, oPlugin);231 if (bHasChangeHandler) {232 if (mRevealAction.changeOnRelevantContainer) {233 //we have the child overlay, so we need the parents234 bRevealEnabled = oPlugin.hasStableId(mParents.relevantContainerOverlay)235 && oPlugin.hasStableId(mParents.parentOverlay);236 } else {237 bRevealEnabled = true;238 }239 if (!mRevealAction.getAggregationName) {240 mRevealAction.getAggregationName = defaultGetAggregationName;241 }242 // Check if the invisible element can be moved to the target aggregation243 if (bRevealEnabled && (sSourceAggregation !== sTargetAggregation)) {244 var oAggregationOverlay = mParents.parentOverlay.getAggregationOverlay(sTargetAggregation);245 return Utils.checkTargetZone(oAggregationOverlay, oOverlay, oPlugin);246 }247 }248 }249 return bRevealEnabled;250 });251 }252 }253 return oHasChangeHandlerPromise.then(function(bIncludeReveal) {254 if (bIncludeReveal) {255 mReveal.elements.push({256 element: oInvisibleElement,257 designTimeMetadata: oDesignTimeMetadata,258 action: mRevealAction,259 sourceAggregation: sSourceAggregation,260 targetAggregation: sTargetAggregation261 });262 var mName = oDesignTimeMetadata.getName(oInvisibleElement);263 if (mName) {264 mReveal.controlTypeNames.push(mName);265 }266 }267 return mReveal;268 });269 }270 /**271 * Calculate a structure with all "add/reveal" action relevant data collected per aggregation:272 * <pre>273 * {274 * <aggregationName> : {275 * addViaDelegate : {276 * designTimeMetadata : <sap.ui.dt.ElementDesignTimeMetadata of parent>,277 * action : <add.delegate action section from designTimeMetadata>278 * },279 * reveal : {280 * elements : [{281 * element : <invisible element>,282 * designTimeMetadata : <sap.ui.dt.ElementDesignTimeMetadata of invisible element>,283 * action : <reveal action section from designTimeMetadata>,284 * sourceAggregation: <aggregation where this element is currently located>285 * }],286 * controlTypeNames : string[] <all controlTypeNames collected via designTimeMetadata>287 * }288 * },289 * <aggregationName2> : ...290 * }291 * </pre>292 *293 * @param {boolean} bSibling - Indicates if the elements should be added as sibling (true) or child (false) to the overlay294 * @param {sap.ui.dt.ElementOverlay} oSourceElementOverlay - Elements will be added in relation (sibling/parent) to this overlay295 * @param {sap.ui.rta.plugin.additionalElements.AdditionalElementsPlugin} oPlugin - Instance of the AdditionalElementsPlugin296 * @param {boolean} [bInvalidate] - Option to prevent cached actions to be returned297 *298 * @return {Promise} Resolving to a structure with all "add/reveal" action relevant data collected299 */300 ActionExtractor.getActions = function(bSibling, oSourceElementOverlay, oPlugin, bInvalidate) {301 var sSiblingOrChild = bSibling ? "asSibling" : "asChild";302 if (!bInvalidate && oSourceElementOverlay._mAddActions) {303 return Promise.resolve(oSourceElementOverlay._mAddActions[sSiblingOrChild]);304 }305 var oRevealActionsPromise = this._getRevealActions(bSibling, oSourceElementOverlay, oPlugin);306 var oAddPropertyActionsPromise = this._getAddViaDelegateActions(bSibling, oSourceElementOverlay, oPlugin);307 return Promise.all([308 oRevealActionsPromise,309 oAddPropertyActionsPromise,310 checkInvalidAddActions(bSibling, oSourceElementOverlay, oPlugin)311 ]).then(function(aAllActions) {312 //join and condense all action data313 var mAllActions = merge(aAllActions[0], aAllActions[1]);314 oSourceElementOverlay._mAddActions = oSourceElementOverlay._mAddActions || {asSibling: {}, asChild: {}};315 oSourceElementOverlay._mAddActions[sSiblingOrChild] = mAllActions;316 return mAllActions;317 });318 };319 /**320 * Returns the already calculated actions of an Overlay, or undefined if no actions available321 * @param {boolean} bSibling - Indicates if the elements should be added as sibling (true) or child (false) to the overlay322 * @param {sap.ui.dt.ElementOverlay} oOverlay - Elements will be added in relation (sibling/parent) to this overlay323 * @returns {object/undefined} - Object with all "add/reveal" action relevant data collected or undefined if no actions available324 */325 ActionExtractor.getActionsOrUndef = function(bSibling, oOverlay) {326 var sSiblingOrChild = bSibling ? "asSibling" : "asChild";327 return oOverlay._mAddActions && oOverlay._mAddActions[sSiblingOrChild];328 };329 /**330 * Returns the Reveal actions data (parameters + elements) for an Overlay331 * @param {boolean} bSibling - If source element overlay should be sibling or parent to the newly added fields332 * @param {sap.ui.dt.ElementOverlay} oSourceElementOverlay - Overlay where the action is triggered333 * @param {sap.ui.rta.plugin.additionalElements.AdditionalElementsPlugin} oPlugin - Instance of the AdditionalElements plugin334 *335 * @returns {Promise<object>} Reveal action data336 */337 ActionExtractor._getRevealActions = function(bSibling, oSourceElementOverlay, oPlugin) {338 var mParents = AdditionalElementsUtils.getParents(bSibling, oSourceElementOverlay, oPlugin);339 var aParents = [mParents.parentOverlay];340 if (mParents.relevantContainer !== mParents.parent) {341 aParents = ElementUtil.findAllSiblingsInContainer(mParents.parent, mParents.relevantContainer).map(function(oParent) {342 return OverlayRegistry.getOverlay(oParent);343 }).filter(function (oOverlay) {344 return oOverlay;345 });346 }347 var aAggregationNames = [];348 if (mParents.parentOverlay) {349 aAggregationNames = mParents.parentOverlay.getAggregationOverlays().filter(function(oAggregationOverlay) {350 return !oAggregationOverlay.getDesignTimeMetadata().isIgnored(mParents.parent);351 }).map(function(oAggregationOverlay) {352 return oAggregationOverlay.getAggregationName();353 });354 return aAggregationNames.reduce(function(oPreviousPromise, sAggregationName) {355 return oPreviousPromise.then(function(mReveal) {356 return getRevealActionFromAggregations(aParents, mReveal, sAggregationName, aAggregationNames, oPlugin);357 });358 }, Promise.resolve({}));359 }360 return Promise.resolve({});361 };362 /**363 * Return the AddViaDelegate action data (parameters + elements) for an Overlay.364 * @param {boolean} bSibling - If source element overlay should be sibling or parent to the newly added fields365 * @param {sap.ui.dt.ElementOverlay} oSourceElementOverlay - Overlay where the action is triggered366 * @param {sap.ui.rta.plugin.additionalElements.AdditionalElementsPlugin} oPlugin - Instance of the AdditionalElementsPlugin367 *368 * @returns {Promise<object>} AddViaDelegate action data369 */370 ActionExtractor._getAddViaDelegateActions = function(bSibling, oSourceElementOverlay, oPlugin) {371 var mParents = AdditionalElementsUtils.getParents(bSibling, oSourceElementOverlay, oPlugin);372 var oDesignTimeMetadata = mParents.parentOverlay && mParents.parentOverlay.getDesignTimeMetadata();373 return Promise.resolve()374 .then(function() {375 var aActions = oDesignTimeMetadata ? oDesignTimeMetadata.getActionDataFromAggregations("add", mParents.parent, undefined, "delegate") : [];376 if (aActions.length) {377 return loadKnownDefaultDelegateLibraries()378 .then(filterValidAddPropertyActions.bind(this, aActions, mParents, oPlugin));379 }380 return [];381 }.bind(this))382 .then(function(aActions) {383 return aActions.reduce(function (oPreviousPromise, oAction) {384 return oPreviousPromise385 .then(function (oReturn) {386 return getAddViaDelegateActionData.call(this, oAction, oDesignTimeMetadata, oPlugin)387 .then(function (mAction) {388 if (mAction) {389 mAction.addPropertyActionData.relevantContainer = mParents.relevantContainer;390 if (!oReturn[mAction.aggregationName]) {391 oReturn[mAction.aggregationName] = {};392 }393 oReturn[mAction.aggregationName].addViaDelegate = mAction.addPropertyActionData;394 }395 return oReturn;396 });397 }.bind(this));398 }.bind(this), Promise.resolve({}));399 }.bind(this));400 };401 return ActionExtractor;...

Full Screen

Full Screen

dom.js

Source:dom.js Github

copy

Full Screen

...122function getFocusableElements (doc) {123 // NOTE: We don't take into account the case of embedded contentEditable124 // elements and specify the contentEditable attribute for focusable elements125 var allElements = doc.querySelectorAll('*');126 var invisibleElements = getInvisibleElements(allElements);127 var inputElementsRegExp = /^(input|button|select|textarea)$/;128 var focusableElements = [];129 var element = null;130 var tagName = null;131 var tabIndex = null;132 var needPush = false;133 for (var i = 0; i < allElements.length; i++) {134 element = allElements[i];135 tagName = getTagName(element);136 tabIndex = getTabIndexAttributeIntValue(element);137 needPush = false;138 if (element.disabled)139 continue;140 if (styleUtils.get(element, 'display') === 'none' || styleUtils.get(element, 'visibility') === 'hidden')...

Full Screen

Full Screen

SimpleForm.designtime-dbg.js

Source:SimpleForm.designtime-dbg.js Github

copy

Full Screen

1/*!2 * UI development toolkit for HTML5 (OpenUI5)3 * (c) Copyright 2009-2017 SAP SE or an SAP affiliate company.4 * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.5 */6// Provides the Design Time Metadata for the sap.ui.layout.form.SimpleForm control7sap.ui.define([], function() {8 "use strict";9 var fnHasContent = function(oFormContainer) {10 if (oFormContainer.getTitle()) {11 return true;12 } else {13 var oSimpleForm = oFormContainer.getParent().getParent();14 return oSimpleForm.getContent().some(function(oControl) {15 return oControl.getVisible();16 });17 }18 };19 return {20 name : function (oElement){21 var sType = oElement.getMetadata().getName();22 if (sType === "sap.ui.layout.form.SimpleForm") {23 return {24 singular : "GROUP_CONTROL_NAME",25 plural : "GROUP_CONTROL_NAME_PLURAL"26 };27 } else if (sType === "sap.ui.layout.form.FormContainer"){28 return {29 singular : "FIELD_CONTROL_NAME",30 plural : "FIELD_CONTROL_NAME_PLURAL"31 };32 }33 },34 aggregations : {35 content : {36 ignore : true37 },38 title : {39 ignore : true40 },41 form : {42 inHiddenTree : true,43 getIndex : function(oForm, oFormContainer) {44 var aFormContainers = oForm.getAggregation("form").getFormContainers();45 if (oFormContainer) {46 return aFormContainers.indexOf(oFormContainer) + 1;47 }48 // if there is no Elements in the FormContainer, the SimpleForm is empty and49 // the index has to be 0, otherwise the SimpleForm doesn't behave as expected.50 if (aFormContainers[0].getFormElements().length === 0 &&51 aFormContainers[0].getTitle() === null) {52 return 0;53 }54 return aFormContainers.length;55 },56 ignore : false,57 childNames : function (oElement){58 var sType = oElement.getMetadata().getName();59 if (sType === "sap.ui.layout.form.SimpleForm") {60 return {61 singular : "GROUP_CONTROL_NAME",62 plural : "GROUP_CONTROL_NAME_PLURAL"63 };64 } else if (sType === "sap.ui.layout.form.FormContainer"){65 return {66 singular : "FIELD_CONTROL_NAME",67 plural : "FIELD_CONTROL_NAME_PLURAL"68 };69 }70 },71 beforeMove : function (oSimpleForm) {72 if (oSimpleForm){73 oSimpleForm._bChangedByMe = true;74 }75 },76 afterMove : function (oSimpleForm) {77 if (oSimpleForm){78 oSimpleForm._bChangedByMe = false;79 }80 },81 actions : {82 move : function(oMovedElement){83 var sType = oMovedElement.getMetadata().getName();84 var oMoveMetadata;85 if (sType === "sap.ui.layout.form.FormContainer"){86 oMoveMetadata = {87 changeType : "moveSimpleFormGroup"88 };89 } else if (sType === "sap.ui.layout.form.FormElement"){90 oMoveMetadata = {91 changeType : "moveSimpleFormField"92 };93 }94 return oMoveMetadata;95 },96 rename : function(oElement){97 var sType = oElement.getMetadata().getName();98 var bIsEnabled = true;99 var oRenameMetadata;100 if (sType === "sap.ui.layout.form.FormContainer"){101 if (oElement.getToolbar() || !oElement.getTitle()) {102 bIsEnabled = false;103 }104 oRenameMetadata = {105 changeType : "renameTitle",106 isEnabled : bIsEnabled,107 domRef : function (oControl){108 if (oControl.getTitle && oControl.getTitle()) {109 return oControl.getTitle().getDomRef();110 }111 }112 };113 } else if (sType === "sap.ui.layout.form.FormElement"){114 oRenameMetadata = {115 changeType : "renameLabel",116 isEnabled : bIsEnabled,117 domRef : function (oControl){118 return oControl.getLabel().getDomRef();119 }120 };121 }122 return oRenameMetadata;123 },124 remove : function(oRemovedElement) {125 var sType = oRemovedElement.getMetadata().getName();126 var sChangeType;127 var bIsEnabled = true;128 if (sType === "sap.ui.layout.form.FormContainer"){129 sChangeType = "removeSimpleFormGroup";130 if (!oRemovedElement.getToolbar() && !fnHasContent.call(this, oRemovedElement)) {131 bIsEnabled = false;132 }133 } else if (sType === "sap.ui.layout.form.FormElement"){134 sChangeType = "hideSimpleFormField";135 } else {136 return undefined;137 }138 return {139 changeType : sChangeType,140 isEnabled : bIsEnabled,141 getConfirmationText : function(oRemovedElement){142 var bContent = false;143 if (oRemovedElement.getMetadata().getName() === "sap.ui.layout.form.FormContainer"144 && oRemovedElement.getToolbar && oRemovedElement.getToolbar()) {145 var aToolbarContent = oRemovedElement.getToolbar().getContent();146 if (aToolbarContent.length > 1) {147 bContent = true;148 } else if ((aToolbarContent.length === 1) &&149 (!aToolbarContent[0].getMetadata().isInstanceOf("sap.ui.core.Label") &&150 !aToolbarContent[0] instanceof sap.ui.core.Title && !aToolbarContent[0] instanceof sap.m.Title)) {151 bContent = true;152 }153 }154 if (bContent) {155 var oTextResources = sap.ui.getCore().getLibraryResourceBundle("sap.ui.layout");156 return oTextResources.getText("MSG_REMOVING_TOOLBAR");157 }158 },159 getState : function(oSimpleForm) {160 var aContent = oSimpleForm.getContent();161 return {162 content : aContent.map(function(oElement) {163 return {164 element : oElement,165 visible : oElement.getVisible ? oElement.getVisible() : undefined,166 index : aContent.indexOf(oElement)167 };168 })169 };170 },171 restoreState : function(oSimpleForm, oState) {172 oSimpleForm.removeAllContent();173 oState.content.forEach(function(oElementState) {174 oSimpleForm.insertContent(oElementState.element, oElementState.index);175 if (oElementState.element.setVisible){176 oElementState.element.setVisible(oElementState.visible);177 }178 });179 }180 };181 },182 createContainer : function(oElement){183 var sType = oElement.getMetadata().getName();184 var oCreateContainerMetadata;185 if (sType === "sap.ui.layout.form.FormElement"){186 return null;187 } else if (sType === "sap.ui.layout.form.SimpleForm") {188 oCreateContainerMetadata = {189 changeType : "addSimpleFormGroup",190 isEnabled : function (oSimpleForm) {191 var oForm = oSimpleForm.getAggregation("form");192 var aFormContainers = oForm.getFormContainers();193 for (var i = 0; i < aFormContainers.length; i++) {194 if (aFormContainers[i].getToolbar && aFormContainers[i].getToolbar()) {195 return false;196 }197 }198 return true;199 },200 getCreatedContainerId : function(sNewControlID) {201 var oTitle = sap.ui.getCore().byId(sNewControlID);202 var sParentElementId = oTitle.getParent().getId();203 return sParentElementId;204 }205 };206 } else if (sType === "sap.ui.layout.form.FormContainer") {207 oCreateContainerMetadata = {208 changeType : "addSimpleFormGroup",209 isEnabled : function (oFormContainer) {210 if (oFormContainer.getToolbar && oFormContainer.getToolbar()) {211 return false;212 }213 return true;214 },215 getCreatedContainerId : function(sNewControlID) {216 var oTitle = sap.ui.getCore().byId(sNewControlID);217 var sParentElementId = oTitle.getParent().getId();218 return sParentElementId;219 }220 };221 }222 return oCreateContainerMetadata;223 },224 reveal : function(oParentElement, sAggregationName) {225 var sType = oParentElement.getMetadata().getName();226 var bRevealableAggregation = sAggregationName ? ( sAggregationName === "formElements" || sAggregationName === "formContainers") : true;227 if (sType === "sap.ui.layout.form.FormContainer" && bRevealableAggregation) {228 return {229 changeType : "unhideSimpleFormField",230 getInvisibleElements : function(oSimpleForm) {231 var aElements = [];232 var aContent = oSimpleForm.getContent();233 aContent.forEach(function(oField) {234 if (oField instanceof sap.m.Label && !oField.getDomRef()) {235 //return FormElements236 aElements.push(oField.getParent());237 }238 });239 return aElements;240 }241 };242 }243 }244 },245 getStableElements : function(oElement) {246 var aStableElements = [];247 var oLabel;248 var oTitleOrToolbar;249 if (oElement.getMetadata().getName() === "sap.ui.layout.form.FormElement") {250 oLabel = oElement.getLabel();251 if (oLabel) {252 aStableElements.push(oLabel);253 }254 aStableElements = aStableElements.concat(oElement.getFields());255 } else if (oElement.getMetadata().getName() === "sap.ui.layout.form.FormContainer") {256 oTitleOrToolbar = oElement.getTitle() || oElement.getToolbar();257 if (oTitleOrToolbar) {258 aStableElements[0] = oTitleOrToolbar;259 }260 oElement.getFormElements().forEach(function(oFormElement) {261 oLabel = oFormElement.getLabel();262 if (oLabel) {263 aStableElements.push(oLabel);264 }265 aStableElements = aStableElements.concat(oFormElement.getFields());266 });267 }268 return aStableElements;269 }270 }271 }272 };...

Full Screen

Full Screen

SimpleForm.designtime.js

Source:SimpleForm.designtime.js Github

copy

Full Screen

1/*!2 * ${copyright}3 */4// Provides the Design Time Metadata for the sap.ui.layout.form.SimpleForm control5sap.ui.define([], function() {6 "use strict";7 var fnHasContent = function(oFormContainer) {8 if (oFormContainer.getTitle()) {9 return true;10 } else {11 var oSimpleForm = oFormContainer.getParent().getParent();12 return oSimpleForm.getContent().some(function(oControl) {13 return oControl.getVisible();14 });15 }16 };17 return {18 name : function (oElement){19 var sType = oElement.getMetadata().getName();20 if (sType === "sap.ui.layout.form.SimpleForm") {21 return {22 singular : "GROUP_CONTROL_NAME",23 plural : "GROUP_CONTROL_NAME_PLURAL"24 };25 } else if (sType === "sap.ui.layout.form.FormContainer"){26 return {27 singular : "FIELD_CONTROL_NAME",28 plural : "FIELD_CONTROL_NAME_PLURAL"29 };30 }31 },32 aggregations : {33 content : {34 ignore : true35 },36 form : {37 inHiddenTree : true,38 getIndex : function(oSimpleForm, oFormContainer) {39 var iIndex = 0;40 var aContent = oSimpleForm.getContent();41 if (oFormContainer) {42 var oTitle = oFormContainer.getTitle();43 if (oTitle !== null) {44 var iTitleIndex = aContent.indexOf(oTitle);45 aContent.some(function(oField, index) {46 if (oField instanceof sap.ui.core.Title && index > iTitleIndex) {47 iIndex = index;48 return true;49 }50 });51 if (iIndex === 0) {52 iIndex = aContent.length;53 }54 }55 } else {56 var aFormContainers = oSimpleForm.getAggregation("form").getFormContainers();57 var oTitle = aFormContainers[aFormContainers.length - 1].getTitle();58 // if there is no Title in the FormContainer, the SimpleForm is empty and59 // the index has to be 0, otherwise the SimpleForm doesn't behave as expected.60 if (oTitle !== null) {61 iIndex = aContent.length;62 }63 }64 return iIndex;65 },66 ignore : false,67 childNames : function (oElement){68 var sType = oElement.getMetadata().getName();69 if (sType === "sap.ui.layout.form.SimpleForm") {70 return {71 singular : "GROUP_CONTROL_NAME",72 plural : "GROUP_CONTROL_NAME_PLURAL"73 };74 } else if (sType === "sap.ui.layout.form.FormContainer"){75 return {76 singular : "FIELD_CONTROL_NAME",77 plural : "FIELD_CONTROL_NAME_PLURAL"78 };79 }80 },81 actions : {82 move : function(oMovedElement){83 var sType = oMovedElement.getMetadata().getName();84 if (sType === "sap.ui.layout.form.FormContainer"){85 return "moveSimpleFormGroup";86 } else if (sType === "sap.ui.layout.form.FormElement"){87 return "moveSimpleFormField";88 }89 },90 rename : function(oElement){91 var sType = oElement.getMetadata().getName();92 var bIsEnabled = true;93 var oRenameMetadata;94 if (sType === "sap.ui.layout.form.FormContainer"){95 if (oElement.getToolbar() || !oElement.getTitle()) {96 bIsEnabled = false;97 }98 oRenameMetadata = {99 changeType : "renameTitle",100 isEnabled : bIsEnabled,101 domRef : function (oControl){102 if (oControl.getTitle && oControl.getTitle()) {103 return oControl.getTitle().getDomRef();104 } else {105 return;106 }107 }108 };109 } else if (sType === "sap.ui.layout.form.FormElement"){110 oRenameMetadata = {111 changeType : "renameLabel",112 isEnabled : bIsEnabled,113 domRef : function (oControl){114 return oControl.getLabel().getDomRef();115 }116 };117 }118 return oRenameMetadata;119 },120 remove : function(oRemovedElement) {121 var sType = oRemovedElement.getMetadata().getName();122 var sChangeType;123 var bIsEnabled = true;124 if (sType === "sap.ui.layout.form.FormContainer"){125 sChangeType = "removeSimpleFormGroup";126 if (!oRemovedElement.getToolbar() && !fnHasContent.call(this, oRemovedElement)) {127 bIsEnabled = false;128 }129 } else if (sType === "sap.ui.layout.form.FormElement"){130 sChangeType = "hideSimpleFormField";131 }132 return {133 changeType : sChangeType,134 isEnabled : bIsEnabled,135 getConfirmationText : function(oRemovedElement){136 var bContent = false;137 if (oRemovedElement.getMetadata().getName() === "sap.ui.layout.form.FormContainer"138 && oRemovedElement.getToolbar && oRemovedElement.getToolbar()) {139 var aToolbarContent = oRemovedElement.getToolbar().getContent();140 if (aToolbarContent.length > 1) {141 bContent = true;142 } else if ((aToolbarContent.length === 1) &&143 (!aToolbarContent[0].getMetadata().isInstanceOf("sap.ui.core.Label") &&144 !aToolbarContent[0] instanceof sap.ui.core.Title && !aToolbarContent[0] instanceof sap.m.Title)) {145 bContent = true;146 }147 }148 if (bContent) {149 var oTextResources = sap.ui.getCore().getLibraryResourceBundle("sap.ui.layout");150 return oTextResources.getText("MSG_REMOVING_TOOLBAR");151 }152 }153 };154 },155 createContainer : function(oElement){156 var sType = oElement.getMetadata().getName();157 var oCreateContainerMetadata;158 if (sType === "sap.ui.layout.form.FormElement"){159 return;160 } else if (sType === "sap.ui.layout.form.SimpleForm") {161 oCreateContainerMetadata = {162 changeType : "addSimpleFormGroup",163 isEnabled : function (oSimpleForm) {164 var oForm = oSimpleForm.getAggregation("form");165 var aFormContainers = oForm.getFormContainers();166 for (var i = 0; i < aFormContainers.length; i++) {167 if (aFormContainers[i].getToolbar && aFormContainers[i].getToolbar()) {168 return false;169 }170 }171 return true;172 },173 containerTitle : "GROUP_CONTROL_NAME",174 getCreatedContainerId : function(sNewControlID) {175 var oTitle = sap.ui.getCore().byId(sNewControlID);176 var sParentElementId = oTitle.getParent().getId();177 return sParentElementId;178 }179 };180 } else if (sType === "sap.ui.layout.form.FormContainer") {181 oCreateContainerMetadata = {182 changeType : "addSimpleFormGroup",183 isEnabled : function (oFormContainer) {184 if (oFormContainer.getToolbar && oFormContainer.getToolbar()) {185 return false;186 }187 return true;188 },189 containerTitle : "GROUP_CONTROL_NAME",190 getCreatedContainerId : function(sNewControlID) {191 var oTitle = sap.ui.getCore().byId(sNewControlID);192 var sParentElementId = oTitle.getParent().getId();193 return sParentElementId;194 }195 };196 }197 return oCreateContainerMetadata;198 },199 reveal : function(oParentElement) {200 var sType = oParentElement.getMetadata().getName();201 if (sType === "sap.ui.layout.form.FormContainer") {202 return {203 changeType : "unhideSimpleFormField",204 getInvisibleElements : function(oSimpleForm) {205 var aElements = [];206 var aContent = oSimpleForm.getContent();207 aContent.forEach(function(oField) {208 if (oField instanceof sap.m.Label && !oField.getDomRef()) {209 //return FormElements210 aElements.push(oField.getParent());211 }212 });213 return aElements;214 }215 };216 }217 }218 },219 getStableElements : function(oElement) {220 var aStableElements = [];221 var oLabel;222 var oTitleOrToolbar;223 if (oElement.getMetadata().getName() === "sap.ui.layout.form.FormElement") {224 oLabel = oElement.getLabel();225 if (oLabel) {226 aStableElements.push(oLabel);227 }228 aStableElements = aStableElements.concat(oElement.getFields());229 } else if (oElement.getMetadata().getName() === "sap.ui.layout.form.FormContainer") {230 oTitleOrToolbar = oElement.getTitle() || oElement.getToolbar();231 if (oTitleOrToolbar) {232 aStableElements[0] = oTitleOrToolbar;233 }234 oElement.getFormElements().forEach(function(oFormElement) {235 oLabel = oFormElement.getLabel();236 if (oLabel) {237 aStableElements.push(oLabel);238 }239 aStableElements = aStableElements.concat(oFormElement.getFields());240 });241 }242 return aStableElements;243 }244 }245 }246 };...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { ClientFunction } from 'testcafe';2test('Getting Invisible Elements', async t => {3 const getInvisibleElements = ClientFunction(() => {4 const elements = document.querySelectorAll('div');5 const invisibleElements = [];6 for (let i = 0; i < elements.length; i++) {7 if (!elements[i].offsetParent) {8 invisibleElements.push(elements[i]);9 }10 }11 return invisibleElements;12 });13 const invisibleElements = await getInvisibleElements();14 console.log(invisibleElements);15});16import { Selector } from 'testcafe';17test('Getting Invisible Elements', async t => {18 const getInvisibleElements = ClientFunction(() => {19 const elements = document.querySelectorAll('div');20 const invisibleElements = [];21 for (let i = 0; i < elements.length; i++) {22 if (!elements[i].offsetParent) {23 invisibleElements.push(elements[i]);24 }25 }26 return invisibleElements;27 });28 const invisibleElements = await getInvisibleElements();29 const element = Selector(invisibleElements[0]);30 await t.expect(element.exists).ok();31});32import { Selector } from 'testcafe';33test('Getting Invisible Elements', async t => {34 const getInvisibleElements = ClientFunction(() => {35 const elements = document.querySelectorAll('div');36 const invisibleElements = [];37 for (let i = 0; i < elements.length; i++) {38 if (!elements[i].offsetParent) {39 invisibleElements.push(elements[i]);40 }41 }42 return invisibleElements;43 });44 const invisibleElements = await getInvisibleElements();45 const element = Selector(() => invisibleElements[0]);46 await t.expect(element.exists).ok();47});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('Getting invisible elements', async t => {3 const select = Selector('select').with({ visibilityCheck: true });4 const options = await select.find('option');5 const invisibleOptions = await t.getInvisibleElements(options);6 await t.expect(invisibleOptions.length).eql(2);7});8import { Selector } from 'testcafe';9test('Getting visible elements', async t => {10 const select = Selector('select').with({ visibilityCheck: true });11 const options = await select.find('option');12 const visibleOptions = await t.getVisibleElements(options);13 await t.expect(visibleOptions.length).eql(2);14});15import { Selector } from 'testcafe';16test('Getting test speed', async t => {17 const speed = await t.getTestSpeed();18 await t.expect(speed).eql(1);19});20import { Selector } from 'testcafe';21test('Setting test speed', async t => {22 .setTestSpeed(0.1)23 .typeText('#developer-name', 'Peter Parker')24 .expect(Selector('#developer-name').value).eql('Peter Parker');25});26import { Selector } from 'testcafe';27test('Debugging', async t => {28 .debug()29 .typeText('#developer-name', 'Peter Parker')30 .expect(Selector('#developer-name').value).eql('Peter Parker');31});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My Test', async t => {3 const invisibleElements = await Selector('.nonexistent').getInvisibleElements();4});5import { Selector } from 'testcafe';6test('My Test', async t => {7 const invisibleElements = await Selector('.nonexistent').getInvisibleElements();8});9import { Selector } from 'testcafe';10test('My Test', async t => {11 const invisibleElements = await Selector('.nonexistent').getInvisibleElements();12});13import { Selector } from 'testcafe';14test('My Test', async t => {15 const invisibleElements = await Selector('.nonexistent').getInvisibleElements();16});17import { Selector } from 'testcafe';18test('My Test', async t => {19 const invisibleElements = await Selector('.nonexistent').getInvisibleElements();20});21import { Selector } from 'testcafe';22test('My Test', async t => {23 const invisibleElements = await Selector('.nonexistent').getInvisibleElements();24});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { ClientFunction } from 'testcafe';2const getInvisibleElements = ClientFunction(() => {3 return Array.from(document.querySelectorAll('*'))4 .filter(el => el.offsetParent === null)5 .map(el => {6 const { display, visibility } = window.getComputedStyle(el);7 return { display, visibility, tagName: el.tagName, className: el.className };8 });9});10test('Getting invisible elements', async t => {11 const invisibleElements = await getInvisibleElements();12 console.log(invisibleElements);13});14import { ClientFunction } from 'testcafe';15const getInvisibleElements = ClientFunction(() => {16 return Array.from(document.querySelectorAll('*'))17 .filter(el => el.offsetParent === null)18 .map(el => {19 const { display, visibility } = window.getComputedStyle(el);20 return { display, visibility, tagName: el.tagName, className: el.className };21 });22});23test('Getting invisible elements', async t => {24 const invisibleElements = await getInvisibleElements();25 console.log(invisibleElements);26});27import { ClientFunction } from 'testcafe';28const getInvisibleElements = ClientFunction(() => {29 return Array.from(document.querySelectorAll('*'))30 .filter(el => el.offsetParent === null)31 .map(el => {32 const { display, visibility } = window.getComputedStyle(el);33 return { display, visibility, tagName: el.tagName, className: el.className };34 });35});36test('Getting invisible elements', async t => {37 const invisibleElements = await getInvisibleElements();38 console.log(invisibleElements);39});40import { ClientFunction } from 'testcafe';41const getInvisibleElements = ClientFunction(() => {42 return Array.from(document.querySelectorAll('*'))43 .filter(el => el.offsetParent === null)

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('Getting invisible elements', async t => {3 const invisibleElements = await Selector('.invisible').getInvisibleElements();4 console.log('Number of invisible elements:', invisibleElements.length);5});6import { Selector } from 'testcafe';7test('Getting invisible elements', async t => {8 const invisibleElements = await Selector('.invisible').getInvisibleElements();9 for (let i = 0; i < invisibleElements.length; i++) {10 console.log('Element #%d is invisible', i + 1);11 }12});13import { Selector } from 'testcafe';14test('Getting invisible elements', async t => {15 const invisibleElements = await Selector('.invisible').getInvisibleElements();16 const filteredElements = invisibleElements.filter(element => element.id === 'invisibleElement');17 console.log('Number of elements with the "invisibleElement" id:', filteredElements.length);18});19import { Selector } from '

Full Screen

Using AI Code Generation

copy

Full Screen

1import {Selector} from 'testcafe';2const getInvisibleElements = Selector((selector) => {3 const elements = document.querySelectorAll(selector);4 return Array.from(elements).filter(element => !element.offsetParent);5});6test('Getting Invisible Elements', async t => {7 const invisibleElements = await getInvisibleElements('.invisible');8 await t.expect(invisibleElements.length).eql(1);9});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('Test', async t => {3 const invisibleElement = Selector('.invisible').with({ visibilityCheck: true });4 const invisibleElements = await t.getInvisibleElements(invisibleElement);5 await t.expect(invisibleElements).ok();6 await t.expect(invisibleElements[0].text).eql('invisible');7});8I have tried to use the getInvisibleElements method, but it always returns an empty array. I have tried to use the Selector method with the option { visibil

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector, t } from 'testcafe';2const getInvisibleElements = require('./getInvisibleElements');3const getInvisibleElements = require('./getInvisibleElements');4test('Get Invisible Elements', async t => {5 const invisibleElements = await getInvisibleElements(Selector('div'));6 console.log(invisibleElements);7});8export default async function getInvisibleElements(selector) {9 const elements = await selector();10 const invisibleElements = [];11 for (let i = 0; i < elements.length; i++) {12 const element = elements[i];13 const elementExists = await element.exists;14 const elementVisible = await element.visible;15 if (elementExists && !elementVisible) {16 invisibleElements.push(element);17 }18 }19 return invisibleElements;20}21 Selector('div')

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testcafe automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful