PropertiesView.js revision d84445f383c4eb7a93a274379edeb69f82ee8810
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2015 ForgeRock AS. All rights reserved.
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*/
/*global define, $, _, Handlebars, form2js, window */
/*jslint evil: true */
], function(AdminAbstractView,
conf,
element: "#mappingContent",
noBaseTemplate: true,
events: {
"click .addProperty": "addProperty",
"click .removePropertyBtn": "removeProperty",
"click .attrTabBtn": "openPropertyEditTab",
"keyup #numRepresentativeProps": "resetNumRepresentativeProps",
"click #updateMappingButton": "saveMapping",
"click #clearChanges": "clearChanges",
"click #missingRequiredPropertiesButton": "addRequiredProperties"
},
sampleDisplay: [],
currentMapping: function(){
return MappingBaseView.currentMapping();
},
checkChanges: function () {
changedProperties = browserStorageDelegate.get(this.currentMapping().name + "_Properties") || currentProperties,
if(changesPending) {
}
else {
}
},
addProperty: function (e) {
e.preventDefault();
eventManager.sendEvent(constants.ROUTE_REQUEST, {routeName: "addMappingProperty", args: [this.mapping.name]});
},
clearChanges: function(e){
e.preventDefault();
},
removeProperty: function (e) {
e.preventDefault();
UIUtils.jqConfirm($.t("templates.mapping.confirmRemoveProperty",{property: $(e.target).attr('target')}),_.bind(function(){
//This is removing the correct row from the stored array
this.checkChanges();
},this));
},
openPropertyEditTab: function(e){
eventManager.sendEvent(constants.ROUTE_REQUEST, {routeName: "editMappingProperty", args: [this.mapping.name, id]});
if(tab === 'condition'){
$("[href=#Condition_Script]").click();
}
else if(tab === 'transform'){
$("[href=#Transformation_Script]").click();
}
else if(tab === 'default'){
$("[href=#Default_Values]").click();
}
},
resetNumRepresentativeProps: function(e){
e.preventDefault();
}
},
checkMissingRequiredProperties: function(){
var props = browserStorageDelegate.get(this.mapping.name + "_Properties") || browserStorageDelegate.get("currentMapping").properties;
}
}, this);
},
addRequiredProperties: function(e){
if(e){
e.preventDefault();
}
}
});
},
var samplePromise = $.Deferred(),
qfe = new QueryFilterEditor();
if(sampleDetails.hasCondition) {
filterCheck = FilterEvaluator.evaluate(qfe.transform(QueryFilterUtils.convertFrom(sampleDetails.condition)), { "linkQualifier": globals.linkQualifier, "object": sampleSource});
if(filterCheck) {
if(sampleDetails.hasTransform) {
result: true
},
});
}, function(e) {
});
} else {
result: true
}
});
}
} else {
result: false
},
transformResults: ""
});
}
} else {
ScriptDelegate.evalScript(sampleDetails.condition, { "linkQualifier": globals.linkQualifier, "object": sampleSource}).then(function(conditionResults){
},
});
}, function(e) {
});
} else {
}
});
}
},
function(e) {
});
}
} else if (sampleDetails.hasTransform) {
});
}, function(e) {
});
} else {
samplePromise.resolve(null);
}
return samplePromise;
},
loadMappingPropertiesGrid: function() {
var _this = this,
mapProps = browserStorageDelegate.get(this.mapping.name + "_Properties") || browserStorageDelegate.get("currentMapping").properties,
autocompleteProps = _.pluck(this.mapping.properties,"source").slice(0,this.data.numRepresentativeProps),
var propCounter = 0;
var sampleData = null,
sourceProp = "",
hasConditionScript = false,
conditionScript = null,
hasTransformScript = false,
transformScript = null;
hasConditionScript = true;
}
hasTransformScript = true;
} else {
}
}
}
} else {
}
} else {
sampleData = "";
}
} else {
} else {
}
}
if(sampleData === null){
}
}
}
}
propCounter++;
return {
"iconDisplay": {
"hasCondition": hasConditionScript,
"conditionScript" : conditionScript,
"hasTransform" : hasTransformScript,
"transformScript" : transformScript
}
};
}).value()
);
},
gridFromMapProps = function (props) {
gridDetailsPromise = $.Deferred(),
evalPromises = [],
globals = {
source : {
}
},
tempDetails = {};
_this.sampleDisplay = [];
if(!_.isEmpty(sampleSource)) {
globals = {
source: {
}
};
tempDetails = {};
} else {
}
}
tempDetails.hasCondition = true;
} else {
tempDetails.hasCondition = false;
}
tempDetails.hasTransform = true;
} else {
tempDetails.hasTransform = false;
}
});
}
var evalResults = arguments;
}, function(e) {
});
} else {
}
return gridDetailsPromise;
},
cols = [
{
"name": "source",
"label": $.t("templates.mapping.source"),
"width": "150px"
},
{
"name": "target",
"label": $.t("templates.mapping.target"),
"width": "175px"
},
{
"name": "iconDisplay",
"label": " ",
"width": "50px",
"align": "center",
"title": false,
var iconElement = "";
} else {
}
}
iconElement = iconElement + '<span class="badge properties-badge" rel="tooltip" data-toggle="popover" data-placement="top" title=""><i class="fa fa-filter"></i>'
+'<div style="display:none;" class="tooltip-details">' + $.t("templates.mapping.conditionalUpon") +'<pre class="text-muted code-tooltip">' +iconDisplay.conditionScript +'</pre></div></span>';
}
iconElement = iconElement + '<span class="badge properties-badge" rel="tooltip" data-toggle="popover" data-placement="top" title=""><i class="fa fa-wrench"></i>'
+'<div style="display:none;" class="tooltip-details">' +$.t("templates.mapping.transformationScriptApplied") +'<pre class="text-muted code-tooltip">' +iconDisplay.transformScript +'</pre></div></span>';
}
return iconElement;
}
},
{
"name": "preview",
"label": '<div id="previewHolder" class="btn-group"><button id="previewDropdownButton" role="button" type="button" class="btn btn-link dropdown-toggle" data-toggle="dropdown" aria-expanded="false">'
+'<span id="previewTitle">Preview </span><span id="previewDropdownType" class="text-muted"></span> <span class="caret"></span>'
+'</button>'
+'<ul id="previewDropDown" class="dropdown-menu" role="menu"></ul></div>',
"classes": "preview-information",
"width": "175px"
},
{
"name": "required",
"label": " ",
"width": "25px",
"align": "center",
"title": false,
return (!required) ? '<i target="' + row.target + '" title="' + $.t("common.form.removeAttribute") + ': ' + row.target + '" class="fa fa-times removePropertyBtn" style="margin-top:4px;"></i>' : '';
}
}
];
mappingUtils.setupSampleSearch($("#findSampleSource",this.$el),this.mapping,autocompleteProps, _.bind(function(item){
sampleSource = item;
datatype: 'local',
}).trigger('reloadGrid');
});
}, this));
$('#mappingTable').jqGrid({
datatype: "local",
height: 'auto',
autowidth: true,
shrinkToFit: true,
pager: 'mappingTable_pager',
hidegrid: false,
cmTemplate: {sortable: false},
onSelectRow: function (id) {
if (id !== "blankRow") {
eventManager.sendEvent(constants.ROUTE_REQUEST, {routeName: "editMappingProperty", args: [_this.mapping.name, id]});
}
},
beforeSelectRow: function (rowid, e) {
return false;
}
return true;
},
loadComplete: function (data) {
var appendElement;
$('#mappingTable').addRowData("blankRow", {"required": true, "target": $.t("templates.mapping.noPropertiesMapped"), "default": "", "script": "", "hasConditionScript": false});
}
$(".properties-badge").popover({
trigger:'hover',
placement:'top',
container: 'body',
html: 'true',
template: '<div class="popover popover-info" role="tooltip"><div class="popover-content"></div></div>'
});
$("#previewDropDown").empty();
$('#previewDropdownButton').dropdown();
appendElement = $('<li><span data-linkQualifier="' + value + '" class="select-preview-item">' + value + '</span></li>');
datatype: 'local',
}).trigger('reloadGrid');
});
});
});
}
}).jqGrid('sortableRows', {
},
}
});
});
},
checkAvailableProperties: function(){
var availableProps;
availableProps = browserStorageDelegate.get(this.mapping.name + "_AvailableObjects").target.properties || [];
if(!availableProps.length || _.difference(availableProps,_.pluck(this.data.mapProps,"target")).length) {
} else {
}
},
MappingBaseView.child = this;
});
}, this));
},
this.mapping = this.currentMapping();
//on the line below the hard-coded "4" is there because it seemed like a generally safe default number of properties to use for the purpose of displaying/searching sample source
this.data.numRepresentativeProps = browserStorageDelegate.get(this.mapping.name + "_numRepresentativeProps",true) || 4;
this.data.requiredProperties = [];
this.data.missingRequiredProperties = [];
}
this.checkMissingRequiredProperties();
this.parentRender(_.bind(function () {
this.loadMappingPropertiesGrid();
this.checkAvailableProperties();
this.checkChanges();
if(callback){
callback();
}
}, this));
}, this));
},
setNumRepresentativePropsLine: function(){
$("#mappingTable", this.$el).find("tr:eq(" + this.data.numRepresentativeProps + ") td").css("border-bottom-width","5px");
},
buildAvailableObjectsMap: function(){
var sourceProm = $.Deferred(),
targetProm = $.Deferred(),
}
}
}, this));
var objTypeMap = {
},
getProps = function(){
});
};
});
}
}, this));
}
}, this);
}, this);
}
});
}, this));
},
saveMapping: function(event) {
var syncMappings;
if(propertyChanges){
}
}
return m;
}, this));
}, this));
}
});
return new PropertiesView();
});