4
1
mirror of https://github.com/Qortal/qortal-ui.git synced 2025-02-12 02:05:51 +00:00

Fixed custom property field format & UI

This commit is contained in:
Justin Ferrari 2023-11-08 10:51:30 -05:00
parent 1d4d797bd8
commit 25f3cd7dc0
2 changed files with 83 additions and 23 deletions

View File

@ -1229,9 +1229,9 @@
"profile8": "Add custom property", "profile8": "Add custom property",
"profile9": "Property name", "profile9": "Property name",
"profile10": "Fields", "profile10": "Fields",
"profile11": "Add new field", "profile11": "Add field",
"profile12": "Field name", "profile12": "Field name",
"profile13": "Fill out", "profile13": "Field value",
"profile14": "Activity", "profile14": "Activity",
"profile15": "No value", "profile15": "No value",
"profile16": "This name has no profile", "profile16": "This name has no profile",
@ -1239,6 +1239,9 @@
"profile18": "Open profile", "profile18": "Open profile",
"profile19": "Cannot fetch profile", "profile19": "Cannot fetch profile",
"profile20": "Register name", "profile20": "Register name",
"profile21": "Insert address from UI" "profile21": "Insert address from UI",
"profile22": "Success",
"profile23": "encrypted",
"profile24": "You must fill out both field name and field value to add a custom property"
} }
} }

View File

@ -36,6 +36,7 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
newFieldName: {type: String}, newFieldName: {type: String},
qortalRequestCustomData: {type: Object}, qortalRequestCustomData: {type: Object},
newCustomDataKey: {type: String}, newCustomDataKey: {type: String},
newCustomDataValue: {type: String},
isSaving: {type: Boolean} isSaving: {type: Boolean}
}; };
} }
@ -75,11 +76,13 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
this.hasFetchedArrr = false; this.hasFetchedArrr = false;
this.isOpenCustomDataModal = false; this.isOpenCustomDataModal = false;
this.customData = {}; this.customData = {};
this.newCustomDataKey = "" this.newCustomDataKey = "";
this.newCustomDataValue = "";
this.newCustomDataField = {}; this.newCustomDataField = {};
this.newFieldName = ''; this.newFieldName = '';
this.isSaving = false this.isSaving = false;
this.addPrivate = this.addPrivate.bind(this);
this.checkForPrivate = this.checkForPrivate.bind(this);
} }
static get styles() { static get styles() {
@ -178,7 +181,6 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
background-color: var(--mdc-theme-surface); background-color: var(--mdc-theme-surface);
width: 80vw; width: 80vw;
max-width: 600px;
padding: 20px; padding: 20px;
box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 6px; box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 6px;
z-index: 1001; z-index: 1001;
@ -190,6 +192,7 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
.modal-overlay.hidden { .modal-overlay.hidden {
display: none; display: none;
} }
.avatar { .avatar {
width: 36px; width: 36px;
height: 36px; height: 36px;
@ -230,6 +233,16 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
background-color: rgb(180, 176, 176); background-color: rgb(180, 176, 176);
border-radius: 7px; border-radius: 7px;
transition: all 0.3s ease-in-out; transition: all 0.3s ease-in-out;
}
.checkbox-row {
position: relative;
display: flex;
align-items: center;
align-content: center;
font-family: Montserrat, sans-serif;
font-weight: 600;
color: var(--black);
} }
`; `;
} }
@ -384,10 +397,16 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
} }
addField(){ addField(){
if (!this.newFieldName || !this.newCustomDataValue) {
let snack5string = get("profile.profile24");
parentEpml.request('showSnackBar', `${snack5string}`);
return;
}
const copyObj = {...this.newCustomDataField} const copyObj = {...this.newCustomDataField}
copyObj[this.newFieldName] = '' copyObj[this.newFieldName] = this.newCustomDataValue
this.newCustomDataField = copyObj this.newCustomDataField = copyObj
this.newFieldName = "" this.newFieldName = ""
this.newCustomDataValue = ""
} }
addCustomData(){ addCustomData(){
@ -397,6 +416,7 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
this.newCustomDataKey = "" this.newCustomDataKey = ""
this.newCustomDataField = {}; this.newCustomDataField = {};
this.newFieldName = '' this.newFieldName = ''
this.newCustomDataValue = ''
this.isOpenCustomDataModal = false; this.isOpenCustomDataModal = false;
} }
@ -406,12 +426,31 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
this.newCustomDataKey = key this.newCustomDataKey = key
} }
removeCustomData(key){ removeCustomData(key){
const copyObj = {...this.customData} const copyObj = {...this.customData}
delete copyObj[key] delete copyObj[key]
this.customData = copyObj this.customData = copyObj
} }
checkForPrivate(){
let isPrivate = false
if(this.newCustomDataKey.includes('-private')) isPrivate = true
return isPrivate
}
addPrivate(e){
if (e.target.checked) {
if(this.newCustomDataKey.includes('-private')){
} else {
this.newCustomDataKey = this.newCustomDataKey + '-private'
}
} else {
this.newCustomDataKey = this.newCustomDataKey.replace('-private', '');
}
}
render() { render() {
return html` return html`
<div class="modal-overlay ${this.isOpen ? '' : 'hidden'}"> <div class="modal-overlay ${this.isOpen ? '' : 'hidden'}">
@ -596,8 +635,17 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
: 'hidden'}" : 'hidden'}"
style="z-index:1001" style="z-index:1001"
> >
<div class="modal-content"> <div class="modal-content" style="max-width: 950px">
<div class="inner-content"> <div class="inner-content">
<div style="display:flex; justify-content:flex-end">
<div class="checkbox-row" style="font-size:16px">
<label for="isPrivate" style="color: var(--black);">
${get('profile.profile23')}
</label>
<mwc-checkbox id="isPrivate" @change=${(e) => this.addPrivate(e)} ?checked=${this.checkForPrivate()}>
</mwc-checkbox>
</div>
</div>
<div style="height:15px"></div> <div style="height:15px"></div>
<div <div
style="display:flex;justify-content:center;flex-direction:column" style="display:flex;justify-content:center;flex-direction:column"
@ -626,8 +674,9 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
/> />
</div> </div>
</div> </div>
<div style="height:15px"></div> <p style=${`${Object.keys(this.newCustomDataField).length ? "margin: 10px 0 10px 0;" : "margin: 10px 0 0 0;"}`}>
<p>${translate('profile.profile10')}</p> ${translate('profile.profile10')}
</p>
<div style="display: flex;flex-direction: column;"> <div style="display: flex;flex-direction: column;">
${Object.keys(this.newCustomDataField).map((key) => { ${Object.keys(this.newCustomDataField).map((key) => {
return html` return html`
@ -644,7 +693,6 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
<div <div
style="display:flex;gap:15px;align-items:center" style="display:flex;gap:15px;align-items:center"
> >
<input <input
id=${key} id=${key}
placeholder=${translate('profile.profile13')} placeholder=${translate('profile.profile13')}
@ -669,20 +717,29 @@ class ProfileModalUpdate extends connect(store)(LitElement) {
`; `;
})} })}
</div> </div>
<div style="height:15px"></div> <div style=${`display: flex; flex-direction: row; align-items: center;justify-content:space-between; ${Object.keys(this.newCustomDataField).length ? "margin-top: 10px" : ""}`}>
<div style="width:100%;display:flex;justify-content:center;gap:10px;margin-top:30px"> <div style="width:100%;display:flex; flex-direction: column; align-items: flex-start;justify-content:center;gap:10px;">
<input <input
placeholder=${translate('profile.profile12')} placeholder=${translate('profile.profile12')}
class="input" class="input"
.value=${this.newFieldName} .value=${this.newFieldName}
@change=${(e) => { @change=${(e) => {
this.newFieldName = e.target.value this.newFieldName = e.target.value
}} }}
/> />
<input
id="value-name"
placeholder=${translate('profile.profile13')}
class="input"
.value=${this.newCustomDataValue}
@change=${(e) => {
this.newCustomDataValue = e.target.value;
}}
/>
</div>
<button <button
class="modal-button" class="modal-button"
style="margin-top: 25px; width: 100px; min-height: 80px;"
@click=${() => { @click=${() => {
this.addField(); this.addField();
}} }}