Skip to content

Commit

Permalink
Merge pull request #38 from BuildFire/fix-navigateto-instance-title
Browse files Browse the repository at this point in the history
Fix navigateto instance title
  • Loading branch information
charkhaw authored May 3, 2023
2 parents 3fd0720 + 2f7c44b commit 6956f5a
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 2 deletions.
72 changes: 70 additions & 2 deletions control/content/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,39 @@
</button>
</div>
</div>
<div class="mdc-layout-grid__inner block">
<span class="mdc-layout-grid__cell--span-2 text-body-light" style="white-space: nowrap;">Selected Feature Title</span>
<div class="mdc-layout-grid__inner mdc-layout-grid__cell--span-6" style="margin-left: 30px;">
<div class="mdc-layout-grid__cell--span-4">
<div class="mdc-form-field">
<div class="mdc-radio">
<input class="mdc-radio__native-control" type="radio" id="defaultTitle" value="default" name="title"
checked onchange="onSelectTitle('default')">
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
<div class="mdc-radio__ripple"></div>
</div>
<label for="defaultTitle" style="white-space: nowrap;">Feature Name</label>
</div>
</div>
<div class="mdc-layout-grid__cell--span-4" style="margin-left: 30px;">
<div class="mdc-form-field">
<div class="mdc-radio">
<input class="mdc-radio__native-control" type="radio" id="topicTitle" value="topic" name="title"
onchange="onSelectTitle('topic')">
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
<div class="mdc-radio__ripple"></div>
</div>
<label for="topicTitle" style="white-space: nowrap;">Topic Title</label>
</div>
</div>
</div>
</div>
<div class="mdc-layout-grid__inner block" id="queryStringContainer">
<span class="mdc-layout-grid__cell--span-2 text-body-light">Query String</span>
<div class="mdc-layout-grid__cell--span-6">
Expand All @@ -59,6 +92,7 @@
</div>
</div>
</div>

<div class="mdc-layout-grid__inner block" style="margin-bottom: 0;">
<span class="mdc-layout-grid__cell--span-2 text-body-light">Topic Privacy</span>
<div class="mdc-layout-grid__inner mdc-layout-grid__cell--span-6">
Expand Down Expand Up @@ -350,12 +384,23 @@


if (result && Object.keys(config.pluginData).length > 0) {
pluginInstanceName.innerHTML = config.pluginData.pluginTypeName + ': ' + config.pluginData.title;
queryStringContainer.style.display = "grid"
getPluginInstance(config.pluginData.instanceId).then(pluginInstance => {
if(pluginInstance && pluginInstance.title !== config.pluginData.title) {
config.pluginData.title = pluginInstance.title;
config.save();
}
pluginInstanceName.innerHTML = config.pluginData.pluginTypeName + ': ' + config.pluginData.title;
queryStringContainer.style.display = "grid"
});
} else {
pluginInstanceName.innerHTML = 'Social Wall'
queryStringContainer.style.display = "none"
}
if (config.featureTitle === Config.TITLE.DEFAULT) {
defaultTitle.checked = true;
} else {
topicTitle.checked = true;
}
if (config.privacy === Config.PRIVACY.PUBLIC) {
publicPrivacy.checked = true;
writeAccessContainer.style.display = "grid";
Expand Down Expand Up @@ -412,6 +457,19 @@
})
}

function getPluginInstance (instanceId) {
return new Promise((resolve, reject) => {
if(!instanceId) resolve(null);
buildfire.pluginInstance.get(instanceId, function(error, instance) {
if (instance) {
resolve(instance);
} else {
resolve(null);
}
});
});
}

function setBothPrivacyElements() {
let elements = document.getElementsByClassName("tagInputContainer");
if (config.writePrivacy === Config.WRITE_PRIVACY.PRIVATE) {
Expand Down Expand Up @@ -477,6 +535,16 @@
config.save();
}

function onSelectTitle(title) {
if (title === 'default') {
config.featureTitle = Config.TITLE.DEFAULT;
}
else if (title === 'topic') {
config.featureTitle = Config.TITLE.TOPIC;
}
config.save();
}

function onSelectWritePrivacy() {
setBothPrivacyElements();
config.save();
Expand Down
8 changes: 8 additions & 0 deletions control/content/js/classes/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Config {
this.emptyStateMessage = dataObj.emptyStateMessage ||'Create your first group now!';
this.navigateToCwByDefault = dataObj.navigateToCwByDefault || false;
this.sortBy = dataObj.sortBy || 'default';
this.featureTitle = dataObj.featureTitle || 'default';
}

static get PRIVACY() {
Expand All @@ -21,6 +22,13 @@ class Config {
}
}

static get TITLE() {
return {
DEFAULT: 'default',
TOPIC: 'topic',
}
}

static get WRITE_PRIVACY() {
return {
PUBLIC: 'public',
Expand Down
6 changes: 6 additions & 0 deletions widget/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ function init() {
.then(result => {
buildfire.spinner.hide();
config = result.data;
if(!config.featureTitle) {
config.featureTitle = 'default';
}
getStrings();
if (config.privacy === Helper.PRIVACY.PRIVATE && !loggedUser) {
enforceUserLogin();
Expand Down Expand Up @@ -802,6 +805,9 @@ function navigateTo(topic) {
} else {
if (topic.originalShareId) pluginData.queryString = 'wid=' + topic.originalShareId + '&privacy=' + topic.privacy;
else pluginData.queryString = queryString + '&privacy=' + topic.privacy;
if(config.featureTitle === 'topic') {
pluginData.title = topic.title;
}
buildfire.navigation.navigateTo(pluginData);
}
}
Expand Down

0 comments on commit 6956f5a

Please sign in to comment.