Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue with the connectors checkboxes not saving properly #5669

Merged
merged 1 commit into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
262 changes: 131 additions & 131 deletions DNN Platform/Connectors/GoogleAnalytics/Scripts/connector.js
Original file line number Diff line number Diff line change
@@ -1,132 +1,132 @@
"use strict";
define(["jquery", "knockout", "templatePath/scripts/config", "templatePath/scripts/PersonaBarDialog"], function ($, ko, cf) {
var helper,
bindViewModel,
rootFolder,
utility,
appId,
appSecret,
container;

var wasDeactivated = false;

var init = function (koObject, connectionHelper, pluginFolder, util) {

helper = connectionHelper;
bindViewModel = koObject;
rootFolder = pluginFolder;
utility = util;
koObject.container = ko.observable("");

if (typeof dnn === "undefined") {
window.Sys = !window.Sys ? window.top.Sys : window.Sys;
window.dnn = !window.dnn ? window.top.dnn : window.dnn;
window.String = !window.String ? window.top.String : window.String;
window.String.format = !window.String.format ? window.top.String.format : window.String.format;
}

};

var onSave = function (conn) {

// Convert boolean to string as the API requires a dictionary of string values
conn.configurations[2].value(conn.configurations[2].value().toString());
conn.configurations[3].value(conn.configurations[3].value().toString());
conn.configurations[4].value(conn.configurations[4].value().toString());
};

var onSaveComplete = function (conn, id) {

// Deactivation / delete handled through the save since the delete function as
// of v9.2.2 only works with multiple connector support. This should be
// considered a temporary workaround until core behaviour updated.

if (wasDeactivated) {

// Was this just deactivated? clear the fields
conn.onDelete(conn, null, null);
wasDeactivated = false;
utility.notify(utility.resx.Connectors.txt_Deleted, true);
}
else {

conn.connected("true");

if (bindViewModel.buttons().length === 1) {

activateDeleteButton(conn);
}
utility.notify((utility.resx.Connectors || utility.resx.PersonaBar).txt_Saved, true);
}
};

var activateDeleteButton = function (conn) {

if (conn.buttons().length === 1) {

conn.buttons.push({
className: "secondarybtn",
text: bindViewModel.resx.btnDelete,
action: function (conn, e) {

// Set the isDeactivating flag to true to override the default save behaviour
// Temporary workaround until delete functionality on connectors is improved
conn.configurations[6].value("true");
wasDeactivated = true;
conn.save(conn, e, onSaveComplete.bind(this, conn, conn.id));
}
});

}

};

var getActionButtons = function () {


if (bindViewModel.connected()) {

return [
{
className: "primarybtn",
text: utility.resx.Connectors.btn_Save,
action: function (conn, e) {
conn.save(conn, e, onSaveComplete.bind(this, conn, conn.id));
}
},

{
className: "secondarybtn",
text: bindViewModel.resx.btnDelete,
action: function (conn, e) {

// Set the isDeactivating flag to true to override the default save behaviour
// Temporary workaround until delete functionality on connectors is improved
conn.configurations[6].value("true");
wasDeactivated = true;
conn.save(conn, e, onSaveComplete.bind(this, conn, conn.id));
}
}
];

} else {

return [
{
className: "primarybtn",
text: utility.resx.Connectors.btn_Save,
action: function (conn, e) {
conn.save(conn, e, onSaveComplete.bind(this, conn, conn.id));
}
}
];
}
};

return {
init: init,
onSave: onSave,
getActionButtons: getActionButtons
};

"use strict";
define(["jquery", "knockout", "templatePath/scripts/config", "templatePath/scripts/PersonaBarDialog"], function ($, ko, cf) {
var helper,
bindViewModel,
rootFolder,
utility,
appId,
appSecret,
container;
var wasDeactivated = false;
var init = function (koObject, connectionHelper, pluginFolder, util) {
helper = connectionHelper;
bindViewModel = koObject;
rootFolder = pluginFolder;
utility = util;
koObject.container = ko.observable("");
if (typeof dnn === "undefined") {
window.Sys = !window.Sys ? window.top.Sys : window.Sys;
window.dnn = !window.dnn ? window.top.dnn : window.dnn;
window.String = !window.String ? window.top.String : window.String;
window.String.format = !window.String.format ? window.top.String.format : window.String.format;
}
};
var onSave = function (conn) {
// Convert boolean to string as the API requires a dictionary of string values
conn.configurations[2].value(conn.configurations[2].value() || 'false');
conn.configurations[3].value(conn.configurations[3].value() || 'false');
conn.configurations[4].value(conn.configurations[4].value() || 'false');
};
var onSaveComplete = function (conn, id) {
// Deactivation / delete handled through the save since the delete function as
// of v9.2.2 only works with multiple connector support. This should be
// considered a temporary workaround until core behaviour updated.
if (wasDeactivated) {
// Was this just deactivated? clear the fields
conn.onDelete(conn, null, null);
wasDeactivated = false;
utility.notify(utility.resx.Connectors.txt_Deleted, true);
}
else {
conn.connected("true");
if (bindViewModel.buttons().length === 1) {
activateDeleteButton(conn);
}
utility.notify((utility.resx.Connectors || utility.resx.PersonaBar).txt_Saved, true);
}
};
var activateDeleteButton = function (conn) {
if (conn.buttons().length === 1) {
conn.buttons.push({
className: "secondarybtn",
text: bindViewModel.resx.btnDelete,
action: function (conn, e) {
// Set the isDeactivating flag to true to override the default save behaviour
// Temporary workaround until delete functionality on connectors is improved
conn.configurations[6].value("true");
wasDeactivated = true;
conn.save(conn, e, onSaveComplete.bind(this, conn, conn.id));
}
});
}
};
var getActionButtons = function () {
if (bindViewModel.connected()) {
return [
{
className: "primarybtn",
text: utility.resx.Connectors.btn_Save,
action: function (conn, e) {
conn.save(conn, e, onSaveComplete.bind(this, conn, conn.id));
}
},
{
className: "secondarybtn",
text: bindViewModel.resx.btnDelete,
action: function (conn, e) {
// Set the isDeactivating flag to true to override the default save behaviour
// Temporary workaround until delete functionality on connectors is improved
conn.configurations[6].value("true");
wasDeactivated = true;
conn.save(conn, e, onSaveComplete.bind(this, conn, conn.id));
}
}
];
} else {
return [
{
className: "primarybtn",
text: utility.resx.Connectors.btn_Save,
action: function (conn, e) {
conn.save(conn, e, onSaveComplete.bind(this, conn, conn.id));
}
}
];
}
};
return {
init: init,
onSave: onSave,
getActionButtons: getActionButtons
};
});
62 changes: 31 additions & 31 deletions DNN Platform/Connectors/GoogleAnalytics/connector.htm
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
<div>

<div>
<label for="txtTrackingID" data-bind="html: configurations[0].localizedName"></label>
<input id="txtTrackingID" data-bind="value: configurations[0].value" type="text" />
</div>

<div>
<label for="txtUrlParameter" data-bind="html: configurations[1].localizedName"></label>
<textarea id="txtUrlParameter" rows="6" data-bind="value: configurations[1].value" type="text"></textarea>
</div>

<div>
<label for="chkTrackAdmins" data-bind="html: configurations[2].localizedName"></label>
<input id="chkTrackAdmins" type="checkbox" data-bind="checked: configurations[2].value, checkedValue: configurations[2].value" />
</div>

<div>
<label for="chkAnonymizeIp" data-bind="html: configurations[3].localizedName"></label>
<input id="chkAnonymizeIp" type="checkbox" data-bind="checked: configurations[3].value, checkedValue: configurations[3].value, disable: configurations[5].value" />

<span data-bind="visible: configurations[5].value, html: configurations[5].localizedName"></span>
</div>

<div>
<label for="chkTrackUserId" data-bind="html: configurations[4].localizedName"></label>
<input id="chkTrackUserId" type="checkbox" data-bind="checked: configurations[4].value, checkedValue: configurations[4].value" />
</div>

<div class="clear"></div>

<div>
<div>
<label for="txtTrackingID" data-bind="html: configurations[0].localizedName"></label>
<input id="txtTrackingID" data-bind="value: configurations[0].value" type="text" />
</div>
<div>
<label for="txtUrlParameter" data-bind="html: configurations[1].localizedName"></label>
<textarea id="txtUrlParameter" rows="6" data-bind="value: configurations[1].value" type="text"></textarea>
</div>
<div>
<label for="chkTrackAdmins" data-bind="html: configurations[2].localizedName"></label>
<input id="chkTrackAdmins" type="checkbox" data-bind="checked: configurations[2].value, checkedValue: 'true'" />
</div>
<div>
<label for="chkAnonymizeIp" data-bind="html: configurations[3].localizedName"></label>
<input id="chkAnonymizeIp" type="checkbox" data-bind="checked: configurations[3].value, checkedValue: 'true', disable: configurations[5].value" />
<span data-bind="visible: configurations[5].value, html: configurations[5].localizedName"></span>
</div>
<div>
<label for="chkTrackUserId" data-bind="html: configurations[4].localizedName"></label>
<input id="chkTrackUserId" type="checkbox" data-bind="checked: configurations[4].value, checkedValue: 'true'" />
</div>
<div class="clear"></div>
</div>
Loading