Skip to content

Commit

Permalink
#1029 and #1030 - Hide fields in Sync Preferences (#1064)
Browse files Browse the repository at this point in the history
* Interim commit to flip to another branch

* more tweaks towards progress

* Laid groundwork for data mapping side, and finished hiding sync preferences options

* Changed sync_pref_field_visibility to hidden_sync_pref_fields

* Typo on equality check.
  • Loading branch information
jmather-c authored Apr 10, 2023
1 parent 935e95a commit 07b1314
Show file tree
Hide file tree
Showing 9 changed files with 239 additions and 126 deletions.
2 changes: 2 additions & 0 deletions sfdx/.forceignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.sfdx/
sfdx/.sfdx/
**/.eslintrc.json
force-app/main/default/featureParameters/**
force-app/main/default/customMetadata/Setup_Connection_Data.Default.md-meta.xml
24 changes: 24 additions & 0 deletions sfdx/force-app/main/default/classes/setupAssistant.cls
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ public with sharing class setupAssistant {
allMappingConfigurations.put('field_defaults', fieldDefaultsMappingsMap);
}
rd.put('allMappingConfigurations', allMappingConfigurations);

rd.put('hiddenMapperFields', getListFieldFromPayload('hidden_mapper_fields', responseBody));
} else {
errorLogger.create('getMappingConfigurations', String.valueOf(response.getStatusCode()), (String)response.getStatus(), 'Failed to get mapping configuration from ruby service.');
}
Expand Down Expand Up @@ -381,6 +383,14 @@ public with sharing class setupAssistant {
for(String readOnlyField : connectionReadOnlyFields) {
rd.put(readOnlyField, String.valueOf(connectionStatus.get(readOnlyField)));
}

List<String> hiddenSyncPrefFields = getListFieldFromPayload('hidden_sync_pref_fields', responseBody, false);
if (hiddenSyncPrefFields == null) {
rd.put('hiddenSyncPrefsFields', new List<String> { 'api-percentage-limit', 'cpq-term-unit' });
} else {
rd.put('hiddenSyncPrefsFields', hiddenSyncPrefFields);

}
}
rd.put('isConnected', true);
rd.put('isCpqInstalled', utilities.isCpqEnabled());
Expand All @@ -391,6 +401,20 @@ public with sharing class setupAssistant {
return rd.getJsonString();
}

private static List<String> getListFieldFromPayload(String listKey, Map<String,Object> responseBody) {
return getListFieldFromPayload(listKey, responseBody, true);
}

private static List<String> getListFieldFromPayload(String listKey, Map<String,Object> responseBody, Boolean ensureList) {
List<String> respFields = (List<String>) responseBody.get(listKey);

if (respFields == null && ensureList) {
return new List<String>();
}

return respFields;
}

//gets multi currency options if it is enablec in the org
@AuraEnabled
public static String getMulticurrencySelectionOptions() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Created by jmather-c on 3/24/23.
*/

.stripe-settings__item {
margin-top: var(--lwc-spacingXLarge, 2rem);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!--
- Created by jmather-c on 3/24/23.
-->

<!-- Sync Preferences Item -->
<template>
<div if:true={displayItem} class={className}>
<slot></slot>
</div>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Created by jmather-c on 3/24/23.
*/

import { LightningElement, api } from 'lwc';

export default class SyncPreferencesItem extends LightningElement {
@api name;
@api toggleFieldVisibilityList;

// controls if the widget is hidden by default
@api hidden = false;

// not proud of this but needed a simple way to remove the added margin for the first item in 'Sync Filters'
@api first = false;

get displayItem() {
// console.log('name', this.name);
// console.log('toggleFieldVisibilityList', JSON.parse(JSON.stringify(this.toggleFieldVisibilityList)));
const isInToggleList = this.toggleFieldVisibilityList.indexOf(this.name) !== -1;
if (this.hidden) {
// if it is not visible by default, then it must be in toggleFieldVisibilityList to be visible
return isInToggleList;
} else {
// if it is visible by default, then it must not be in toggleFieldVisibilityList to still be visible
return isInToggleList === false;
}

}

get className() {
const activeClass = this.first ? 'stripe-settings__item_first' : 'stripe-settings__item';
return this.displayItem ? activeClass : 'stripe-settings__item_disabled';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>54.0</apiVersion>
<description>Sync Preferences Item</description>
<isExposed>false</isExposed>
<masterLabel>Sync Preferences Item</masterLabel>
</LightningComponentBundle>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
margin-top: var(--lwc-spacingXLarge, 2rem);
}

.stripe-settings__item + c-sync-preferences-item {
margin-top: var(--lwc-spacingXLarge, 2rem);
}

c-sync-preferences-item + .stripe-settings__item {
margin-top: var(--lwc-spacingXLarge, 2rem);
}

c-sync-preferences-item + c-sync-preferences-item {
margin-top: var(--lwc-spacingXLarge, 2rem);
}

.stripe-icon_inline {
transform: translateY(-2px);
}
Loading

0 comments on commit 07b1314

Please sign in to comment.