Skip to content

Commit

Permalink
add settings to change feature title on navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
hadihakim committed Apr 28, 2023
1 parent 161e16d commit b817011
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
50 changes: 50 additions & 0 deletions control/content/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,41 @@
</div>
</div>
</div>

<div class="mdc-layout-grid__inner block">
<span class="mdc-layout-grid__cell--span-2 text-body-light">Feature Title</span>
<div class="mdc-layout-grid__inner mdc-layout-grid__cell--span-6">
<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">Default</label>
</div>
</div>
<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="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">Topic Title</label>
</div>
</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 @@ -362,6 +397,11 @@
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 @@ -496,6 +536,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 b817011

Please sign in to comment.