Skip to content

Commit

Permalink
'Clear All Notifications' action has been developed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Onur Menal committed Apr 13, 2020
1 parent 1cee342 commit 9446223
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 29 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "crm-power-pane",
"version": "1.2.1",
"version": "1.2.2",
"description": "Dynamics 365 Power Pane is a helper tool designed to integrate with Dynamics CRM/365 application and allow you to manipulate forms.",
"main": "index.js",
"scripts": {
Expand Down
Binary file modified src/assets/img/action-icons/clear-all-notifications.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/img/action-icons/go-to-create-form.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/html/ui/pane.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@
<!--<li class="crm-power-pane-subgroup" id="show-auto-fill"><span><span class="icon auto-fill"></span>Form Auto Fill</span></li>-->
<li class="crm-power-pane-subgroup" id="refresh-ribbon"><span><span class="icon refresh-ribbon-icon"></span>Refresh Ribbon</span></li>
<li class="crm-power-pane-subgroup" id="refresh-form"><span><span class="icon refresh-form-icon"></span>Refresh Form</span></li>
<li class="crm-power-pane-subgroup" id="toggle-lookup-links"><span><span class="icon toggle-lookup-links-icon"></span>Toggle lookup links</span></li>
<li class="crm-power-pane-subgroup" id="toggle-lookup-links"><span><span class="icon toggle-lookup-links-icon"></span>Toggle Lookup Links</span></li>
</ul>
<ul class="crm-power-pane-section" id="form-actions">
<li class="crm-power-pane-header">Navigations</li>
<li class="crm-power-pane-subgroup" id="go-to-record"><span><span class="icon go-to-record-icon"></span>Go to Record by Id</span></li>
<li class="crm-power-pane-subgroup" id="go-to-create-form"><span><span class="icon go-to-create-form"></span>Go to Create Form</span></li>
<li class="crm-power-pane-subgroup" id="open-entity-editor"><span><span class="icon entity-editor-icon"></span>Entity Editor</span></li>
<li class="crm-power-pane-subgroup" id="solutions"><span><span class="icon solutions-icon"></span>Solutions</span></li>
<li class="crm-power-pane-subgroup" id="crm-diagnostics"><span><span class="icon crm-diagnostics-icon"></span>Crm Diagnostics</span></li>
<li class="crm-power-pane-subgroup" id="performance-center"><span><span class="icon performance-center-icon"></span>Performance Center</span></li>
<li class="crm-power-pane-subgroup" id="mobile-express"><span><span class="icon mobile-icon"></span>Mobile Express</span></li>
<li class="crm-power-pane-subgroup" id="mobile-client"><span><span class="icon mobile-icon"></span>Mobile Client</span></li>
</ul>
<!--
Expand Down
15 changes: 11 additions & 4 deletions src/js/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,14 @@
}

function InjectSource(sources) {
body = document.querySelector('body[scroll=no]') || document.querySelector('body');

var isPowerPaneInjected = Array.from(window.top.document.scripts).find(function (elem) { return elem.src.indexOf("ui/js/pane.js") > -1 });

if (isPowerPaneInjected != undefined) { //power pane already injected
return;
}

body = window.top.document.querySelector('body[scroll=no]') || window.top.document.querySelector('body');

sources.forEach(function (s) {
body.appendChild(s);
Expand All @@ -92,7 +99,7 @@
var applicationType = GetAppicationType();

if (applicationType == ApplicationType.DynamicsCRM) {
var ribbon = document.querySelector('#navBar');
var ribbon = window.top.document.querySelector('#navBar');

if (ribbon) {
ribbon.prepend(powerPaneButton);
Expand All @@ -101,7 +108,7 @@
return true;

} else if (applicationType == ApplicationType.Dynamics365) {
var officeWaffle = document.querySelector("button[data-id=officewaffle]");
var officeWaffle = window.top.document.querySelector("button[data-id=officewaffle]");

if (officeWaffle) {
officeWaffle.before(powerPaneButton);
Expand Down Expand Up @@ -143,7 +150,7 @@

var style = BuildSytleTag(browser.extension.getURL("ui/css/pane.css"));
var script = BuildScriptTag(browser.extension.getURL("ui/js/pane.js"));

InjectSource([style, script, content]);
}
else if (xmlHttp.status == 400) {
Expand Down
71 changes: 52 additions & 19 deletions src/js/ui/pane.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,14 @@ $(function () {
Xrm = CrmPowerPane.TargetFrame.GetXrm();
});

$("#crm-power-pane-button").click(function (e) {

$(document).on("click", "#crm-power-pane-button", function (e) {
$(".crm-power-pane-sections").slideToggle(CrmPowerPane.Constants.SlideTime);
e.stopPropagation();
});

// Hide the pane if it is already open and the user clicked somewhere else.
$(window).on("click", function () {
$(document).on("click", function () {
$(".crm-power-pane-sections").delay(100).slideUp(CrmPowerPane.Constants.SlideTime);
});

Expand Down Expand Up @@ -543,7 +544,7 @@ $(function () {
}
]);
} catch (e) {
CrmPowerPane.Errors.WrongPageWarning();
CrmPowerPane.UI.ShowNotification("An error occurred while getting the user information.","error");
}
});

Expand Down Expand Up @@ -800,10 +801,6 @@ $(function () {
window.open(Content.Xrm.Page.context.getClientUrl() + "/tools/diagnostics/diag.aspx");
});

$("#mobile-express").click(function () {
window.open(Content.Xrm.Page.context.getClientUrl() + "/m");
});

$("#mobile-client").click(function () {
var url = Content.Xrm.Page.context.getClientUrl();
window.open(url + "/nga/main.htm?org=" + Content.Xrm.Page.context.getOrgUniqueName() + "&server=" + url);
Expand All @@ -829,12 +826,16 @@ $(function () {
});

$("#clear-all-notifications").click(function () {
Xrm.Page.ui.controls.forEach(function (c) {
try {
c.clearNotification();
} catch (e) { }
});
CrmPowerPane.UI.ShowNotification("Notifications of all fields have been cleared.");
try {
Xrm.Page.ui.controls.forEach(function (c) {
try {
c.clearNotification();
} catch (e) { }
});
CrmPowerPane.UI.ShowNotification("Notifications of all fields have been cleared.");
} catch (e) {
CrmPowerPane.Errors.WrongPageWarning();
}
});

$("#open-entity-editor").click(function () {
Expand All @@ -853,14 +854,18 @@ $(function () {
}
],
function (popupObj) {
var params = popupObj.Parameters;
var entityName = params.entityname.value;
var entityTypeCode = Xrm.Internal.getEntityCode(entityName);
var entityDetail = "";
var entityName = popupObj.Parameters.entityname.value;
if (entityName && entityName.trim() != "") {
var entityTypeCode = Xrm.Internal.getEntityCode(entityName);
var entitiesCategoryCode = 9801; // undocumented
entityDetail = "&def_category=" + entitiesCategoryCode + "&def_type=" + entityTypeCode
}

// ref https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/gg328257(v=crm.8)?redirectedfrom=MSDN#constant-solutionid-values
var defaultSolutionId = "{FD140AAF-4DF4-11DD-BD17-0019B9312238}";
var entitiesCategoryCode = 9801; // undocumented
window.open(Content.Xrm.Page.context.getClientUrl() + "/tools/solution/edit.aspx?id=" + defaultSolutionId + "&def_category=" + entitiesCategoryCode + "&def_type=" + entityTypeCode)

window.open(Content.Xrm.Page.context.getClientUrl() + "/tools/solution/edit.aspx?id=" + defaultSolutionId + entityDetail);
});
} catch (e) {
CrmPowerPane.UI.ShowNotification("An error ocurred while redirecting to entity editor.", "error");
Expand Down Expand Up @@ -1014,7 +1019,7 @@ $(function () {

$("#clone-record").click(function () {
try {
var excludedFields = ["createdon", "createdby", "modifiedon", "modifiedby", "ownerid","vrp_numberofchildincidents"];
var excludedFields = ["createdon", "createdby", "modifiedon", "modifiedby", "ownerid"];
var collectedFields = [];

Xrm.Page.data.entity.attributes.forEach(function (a) {
Expand Down Expand Up @@ -1146,6 +1151,34 @@ $(function () {
$("#solutions").click(function () {
window.open(Xrm.Page.context.getClientUrl() +"/tools/Solution/home_solution.aspx?etc=7100" , '_blank');
});

$("#go-to-create-form").click(function () {
try {
CrmPowerPane.UI.BuildInputPopup(
"Go to create form",
"Redirects you to create form of specified entity. ",
[
{
label: "Entity Schema Name",
name: "entityname"
}
],
function (popupObj) {
var params = popupObj.Parameters;
if (params.entityname.value) {
var linkProps = [Xrm.Page.context.getClientUrl() + "/main.aspx"];
linkProps.push("?etn=" + params.entityname.value.toLowerCase());
linkProps.push("&newWindow=true");
linkProps.push("&pagetype=entityrecord");
window.open(linkProps.join(""), '_blank');
} else {
CrmPowerPane.UI.ShowNotification("Entity name is required. Please fill it and try again.", "warning");
}
});
} catch (e) {
CrmPowerPane.UI.ShowNotification("An error ocurred while redirecting to specified create form.", "error");
}
});
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/sass/ui/pane.scss
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ $browserPrefix: 'chrome-extension://__MSG_@@extension_id__' !default;
background: url('#{$browserPrefix}/img/action-icons/robot.png');
}

span.create-form {
background: url('#{$browserPrefix}/img/action-icons/create.png');
span.go-to-create-form {
background: url('#{$browserPrefix}/img/action-icons/go-to-create-form.png');
}
}

Expand Down

0 comments on commit 9446223

Please sign in to comment.