Skip to content

Commit

Permalink
Commit (Pre separate Dimensions/Measures)
Browse files Browse the repository at this point in the history
Update and Delete selected (Pre split)
  • Loading branch information
GINQO authored Dec 3, 2018
1 parent 685fe97 commit 96e5ac9
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 11 deletions.
110 changes: 103 additions & 7 deletions GINQO_MasterItemManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ define(['jquery', 'qlik', 'text!./template.ng.html', 'text!./dialog-template.ng.
var arrayMeasures = [];
var arrayDimensions = [];
swal({
title: "Are you sure?",
title: "Create Master Items?",
text: "",
icon: "info",
buttons: true,
Expand Down Expand Up @@ -231,18 +231,93 @@ define(['jquery', 'qlik', 'text!./template.ng.html', 'text!./dialog-template.ng.

app.doReload(0, true, false);

swal("Master Items created!", {
swal({
title:"Master Items created!",
icon: "success",
});
} else {
swal("Master Items not created.");
swal({
title:"Master Items not created."
});
}
});




}

$scope.UpdateSelected = function() {
// For each element that exists in MIM Definition => Do something
measurevalues.rows.forEach(row => {
enigma.app.getMeasure(row.cells[6].qText).then(reply =>{
reply.setProperties({
"qInfo": {
"qType": "measure",
"qId": row.cells[6].qText.replace("-", "")
},
"qMeasure": {
"qLabel": row.cells[0].qText.replace("-", ""),
"qDef": row.cells[3].qText.replace("-", ""),
"qGrouping": "N",
"qLabelExpression": `${row.cells[2].qText.replace("-", "")}`, // wrap this string in ='' so Qlik understands it as an expression
"qExpressions": [],
"coloring": {
"baseColor": {
"color": row.cells[5].qText.replace("-", ""),
"index": -1
},
},
"qActiveExpression": 0
},
"qMetaDef": {
"title": row.cells[0].qText.replace("-", ""),
"description": `${row.cells[1].qText.replace("-", "")}`, // Description:
"tags": [row.cells[4].qText.replace("-", "")], //Tags:
}
}).then(reply => {
swal({
text:"Master Items Updated."
})
})
})
});
dimensionvalues.rows.forEach(row => {
enigma.app.getDimension(row.cells[6].qText).then(reply =>{
reply.setProperties({
"qInfo": {
"qType": "dimension",
"qId": row.cells[6].qText.replace("-", "")
},
"qDim": {
// "title": "something",
"qGrouping": "N",
"qLabelExpression": `${row.cells[2].qText.replace('-', '')}`,
"qFieldDefs": [
row.cells[1].qText.replace("-", "") //Dimension Field:
],
//"qFieldLabels": ["TEST"],
"title": row.cells[0].qText.replace("-", ""),
"coloring": {
"baseColor": {
"color": row.cells[4].qText.replace("-", ""), // Dimension Color:
"index": -1
},
},
},
"qMetaDef": {
"title": row.cells[0].qText.replace("-", ""), //Dimension Name
"description": row.cells[3].qText.replace("-", ""), //Desciption:
"tags": [row.cells[5].qText.replace("-", "")], //Tags
}
}).then(reply => {
swal({
text:"Master Items Updated."
})
})
})
});
};
// List all Master Items for Import
$scope.ListImportMasterItems = function () {
app.createGenericObject({
Expand All @@ -257,8 +332,8 @@ define(['jquery', 'qlik', 'text!./template.ng.html', 'text!./dialog-template.ng.
// Destroy Master items
$scope.DestroyAllMeasures = function () {
swal({
title: "Are you sure?",
text: "Click OK to delete Master Items (Dimensions and Metrics). Visualizations will NOT be deleted.",
title: "Are you sure you want to Delete All Master items?",
text: "Visualizations will NOT be affected.",
icon: "warning",
buttons: true,
dangerMode: true,
Expand Down Expand Up @@ -317,17 +392,38 @@ define(['jquery', 'qlik', 'text!./template.ng.html', 'text!./dialog-template.ng.
})
})
})
swal("Master items have been deleted.", {
swal({
title: "Master items have been deleted.",
icon: "success",
});
} else {
swal("Not deleted");
swal({
title:"Not deleted"
});
}
});


};

$scope.DestroyDimension = function () {
// The Engine API DestroyMeasure function: https://help.qlik.com/en-US/sense-developer/September2018/APIs/EngineAPI/services-Doc-DestroyMeasure.html
console.log("Test")

dimensionvalues.rows.forEach(element => {
enigma.app.destroyDimension(element.cells[6].qText)
})
// console.log(dimensionvalues.rows)
}

$scope.DestroyMeasure = function(){
measurevalues.rows.forEach(element => {
enigma.app.destroyMeasure(element.cells[6].qText)
});
}



/*********************************************************************************************************************************************/
/*************************** RETRIEVE OBJECTS FOR MASTER ITEM DATA, EXPORT TO CSV ****************************************************/
/*********************************************************************************************************************************************/
Expand Down
20 changes: 16 additions & 4 deletions template.ng.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
transform: translate(-50%, -50%);
}
.masteritembutton{
width: 250px
width: 340px
}
.masteritemdelete{
width:170px
}
.masteritemdeleteall{
width:100px
}
.instructions{
width:250px
Expand Down Expand Up @@ -41,14 +47,20 @@
<button title="Export Variables" style="left: 0%" ng-click="ExportVariables()" class="lui-button lui-button--default">
<span class="lui-fade-button__icon lui-icon lui-icon--variables"></span>
</button>
<button ng-click="DestroyAllMeasures();" style="left: 0%" class="lui-button lui-button--danger">
<span class="lui-fade-button__icon lui-icon lui-icon--disconnect"></span>
</button>
</div>
<br><br><br>
<h1><span class="lui-icon lui-icon--cogwheel" aria-hidden="true"></span> Import Master Items</h1>
<br>
<button ng-click="CreateMeasure();" class="masteritembutton lui-button lui-button">Create</button><br>
<button ng-click="UpdateMeasures();" class="masteritembutton lui-button lui-button">Update</button><br>
<button ng-click="DestroyAllMeasures();" class="masteritembutton lui-button lui-button--default">Delete</button>

<button ng-click="UpdateSelected();" class="masteritembutton lui-button lui-button">Update</button><br>
<div class="lui-buttongroup">
<button ng-click="DestroyDimension();" class="masteritemdelete lui-button lui-button--default">Delete Dimensions</button>
<button ng-click="DestroyMeasure();" class="masteritemdelete lui-button lui-button--default">Delete Measure</button>

</div>
<!-- <button class="instructions lui-button" ng-click="openDialog()">Instructions: </button> -->

</div>
Expand Down

0 comments on commit 96e5ac9

Please sign in to comment.