Add read-only mode to map and array editors
This commit is contained in:
parent
8a4c19dd17
commit
46bfac7540
13 changed files with 174 additions and 79 deletions
1
frontend-reactive/app/components/account/full.hbs
Normal file
1
frontend-reactive/app/components/account/full.hbs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{{yield}}
|
1
frontend-reactive/app/components/account/overview.hbs
Normal file
1
frontend-reactive/app/components/account/overview.hbs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{{yield}}
|
|
@ -1,29 +1,29 @@
|
||||||
import { action } from '@ember/object'
|
import { action } from '@ember/object';
|
||||||
import Component from '@glimmer/component'
|
import Component from '@glimmer/component';
|
||||||
import { tracked } from '@glimmer/tracking'
|
import { tracked } from '@glimmer/tracking';
|
||||||
import isValidMail from 'frontend-reactive/helpers/is-valid-mail'
|
import isValidMail from 'frontend-reactive/helpers/is-valid-mail';
|
||||||
|
|
||||||
export interface AuthPostRegistrationFormSignature {
|
export interface AuthPostRegistrationFormSignature {
|
||||||
// The arguments accepted by the component
|
// The arguments accepted by the component
|
||||||
Args: {
|
Args: {
|
||||||
username: string
|
username: string;
|
||||||
}
|
};
|
||||||
// Any blocks yielded by the component
|
// Any blocks yielded by the component
|
||||||
Blocks: {
|
Blocks: {
|
||||||
default: []
|
default: [];
|
||||||
}
|
};
|
||||||
// The element to which `...attributes` is applied in the component template
|
// The element to which `...attributes` is applied in the component template
|
||||||
Element: null
|
Element: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class AuthPostRegistrationForm extends Component<AuthPostRegistrationFormSignature> {
|
export default class AuthPostRegistrationForm extends Component<AuthPostRegistrationFormSignature> {
|
||||||
@tracked displayname: string = this.args.username
|
@tracked displayname: string = this.args.username;
|
||||||
@tracked description: string = ''
|
@tracked description: string = '';
|
||||||
@tracked gender: Array<{ value: string }> = []
|
@tracked gender: Array<{ value: string }> = [];
|
||||||
@tracked beingTypes: Array<{
|
@tracked beingTypes: Array<{
|
||||||
name: string
|
name: string;
|
||||||
checked: boolean
|
checked: boolean;
|
||||||
description: string
|
description: string;
|
||||||
}> = [
|
}> = [
|
||||||
{
|
{
|
||||||
name: 'Human',
|
name: 'Human',
|
||||||
|
@ -55,22 +55,22 @@ export default class AuthPostRegistrationForm extends Component<AuthPostRegistra
|
||||||
description: 'Doll',
|
description: 'Doll',
|
||||||
checked: false,
|
checked: false,
|
||||||
},
|
},
|
||||||
]
|
];
|
||||||
@tracked defaultpostmode: string = 'Public'
|
@tracked defaultpostmode: string = 'Public';
|
||||||
@tracked followapproval: boolean = false
|
@tracked followapproval: boolean = false;
|
||||||
@tracked customProperties: Array<{ key: string; value: string }> = []
|
@tracked customProperties: Array<{ key: string; value: string }> = [];
|
||||||
@tracked indexable: boolean = true
|
@tracked indexable: boolean = true;
|
||||||
@tracked mail = { mail: '', valid: false }
|
@tracked mail = { mail: '', valid: false };
|
||||||
@tracked enableBlueskyIntegration = false
|
@tracked enableBlueskyIntegration = false;
|
||||||
|
|
||||||
genderAddedHandler(newIndex: number) {
|
genderAddedHandler(newIndex: number) {
|
||||||
console.log('gender added')
|
console.log('gender added');
|
||||||
}
|
}
|
||||||
genderRemovedHandler(removedIndex: number) {
|
genderRemovedHandler(removedIndex: number) {
|
||||||
console.log('gender removed')
|
console.log('gender removed');
|
||||||
}
|
}
|
||||||
|
|
||||||
@action test() {
|
@action test() {
|
||||||
console.log(this.mail)
|
console.log(this.mail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<div class="mail-entry {{@wrapper-classes}}">
|
<div class="mail-entry {{@wrapper-classes}}">
|
||||||
<label>
|
<label>
|
||||||
Email
|
Email
|
||||||
<!--<div class="filling-spacer"/>-->
|
{{!--<div class="filling-spacer"/>--}}
|
||||||
<Input
|
<Input
|
||||||
class="mail-input {{if this.mailOk "mail-input-ok" "mail-input-error"}} {{@input-classes}}"
|
class="mail-input {{if this.mailOk "mail-input-ok" "mail-input-error"}} {{@input-classes}}"
|
||||||
@type="text"
|
@type="text"
|
||||||
|
|
|
@ -1,4 +1,16 @@
|
||||||
<div class="{{@wrapper-classes}}">
|
<div class="{{@wrapper-classes}}">
|
||||||
|
{{#if @readonly}}
|
||||||
|
<ul>
|
||||||
|
{{#each this.args.list as |element|}}
|
||||||
|
<li>
|
||||||
|
<div class="string-array-element-wrapper">
|
||||||
|
<p class="{{@element-key-classes}}">{{element.key}}</p>
|
||||||
|
<p class="{{@element-value-classes}}">{{element.value}}</p>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{{/each}}
|
||||||
|
</ul>
|
||||||
|
{{else}}
|
||||||
<ul>
|
<ul>
|
||||||
{{#each this.args.list as |element index|}}
|
{{#each this.args.list as |element index|}}
|
||||||
<li>
|
<li>
|
||||||
|
@ -24,4 +36,5 @@
|
||||||
>
|
>
|
||||||
Add element
|
Add element
|
||||||
</div>
|
</div>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
|
@ -1,4 +1,15 @@
|
||||||
<div class={{@wrapper-class}}>
|
<div class={{@wrapper-class}}>
|
||||||
|
{{#if @readonly}}
|
||||||
|
<ul>
|
||||||
|
{{#each this.args.elements as |element|}}
|
||||||
|
{{#if element.checked}}
|
||||||
|
<li>
|
||||||
|
<p>{{element.name}}</p>
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
{{/each}}
|
||||||
|
</ul>
|
||||||
|
{{else}}
|
||||||
{{#each this.args.elements as |element|}}
|
{{#each this.args.elements as |element|}}
|
||||||
<label class={{@label-class}}>
|
<label class={{@label-class}}>
|
||||||
{{element.description}}
|
{{element.description}}
|
||||||
|
@ -11,4 +22,5 @@
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
|
@ -1,4 +1,7 @@
|
||||||
<div class="{{@wrapper-class}}">
|
<div class="{{@wrapper-class}}">
|
||||||
|
{{#if @readonly}}
|
||||||
|
<p class="{{@element-classes}}">{{@selected}}</p>
|
||||||
|
{{else}}
|
||||||
{{#each @elements as |element index|}}
|
{{#each @elements as |element index|}}
|
||||||
<RadioButton
|
<RadioButton
|
||||||
@value="{{element}}"
|
@value="{{element}}"
|
||||||
|
@ -9,4 +12,5 @@
|
||||||
{{element}}
|
{{element}}
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
|
@ -1,4 +1,11 @@
|
||||||
<div class="{{@wrapper-classes}}">
|
<div class="{{@wrapper-classes}}">
|
||||||
|
{{#if @readonly}}
|
||||||
|
<ul>
|
||||||
|
{{#each this.args.list as |element|}}
|
||||||
|
<p class="{{@readonly-element-classes}}">{{element.value}}</p>
|
||||||
|
{{/each}}
|
||||||
|
</ul>
|
||||||
|
{{else}}
|
||||||
<ul>
|
<ul>
|
||||||
{{#each this.args.list as |element index|}}
|
{{#each this.args.list as |element index|}}
|
||||||
<li>
|
<li>
|
||||||
|
@ -27,4 +34,5 @@
|
||||||
>
|
>
|
||||||
Add element
|
Add element
|
||||||
</div>
|
</div>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
|
@ -29,7 +29,9 @@
|
||||||
|
|
||||||
.registration-form-mail-input {
|
.registration-form-mail-input {
|
||||||
width: max-content;
|
width: max-content;
|
||||||
|
|
||||||
/* display: flex; */
|
/* display: flex; */
|
||||||
|
|
||||||
/* flex-grow: 1; */
|
/* flex-grow: 1; */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,12 @@
|
||||||
|
|
||||||
.mail-input-ok {
|
.mail-input-ok {
|
||||||
border: 1px solid green;
|
border: 1px solid green;
|
||||||
box-shadow: 0px 0px 5px green;
|
box-shadow: 0 0 5px green;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mail-input-error {
|
.mail-input-error {
|
||||||
border: 1px solid red;
|
border: 1px solid red;
|
||||||
box-shadow: 0px 0px 5px red;
|
box-shadow: 0 0 5px red;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mail-status {
|
.mail-status {
|
||||||
|
@ -27,7 +27,9 @@
|
||||||
|
|
||||||
.mail-ok {
|
.mail-ok {
|
||||||
color: green;
|
color: green;
|
||||||
|
|
||||||
/* margin-top: -0.25lh; */
|
/* margin-top: -0.25lh; */
|
||||||
|
|
||||||
/* margin-bottom: -0.28lh; */
|
/* margin-bottom: -0.28lh; */
|
||||||
font-size: 0.9lh;
|
font-size: 0.9lh;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
import { module, test } from 'qunit';
|
||||||
|
import { setupRenderingTest } from 'frontend-reactive/tests/helpers';
|
||||||
|
import { render } from '@ember/test-helpers';
|
||||||
|
import { hbs } from 'ember-cli-htmlbars';
|
||||||
|
|
||||||
|
module('Integration | Component | account/full', function (hooks) {
|
||||||
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
|
test('it renders', async function (assert) {
|
||||||
|
// Set any properties with this.set('myProperty', 'value');
|
||||||
|
// Handle any actions with this.set('myAction', function(val) { ... });
|
||||||
|
|
||||||
|
await render(hbs`<Account::Full />`);
|
||||||
|
|
||||||
|
assert.dom().hasText('');
|
||||||
|
|
||||||
|
// Template block usage:
|
||||||
|
await render(hbs`
|
||||||
|
<Account::Full>
|
||||||
|
template block text
|
||||||
|
</Account::Full>
|
||||||
|
`);
|
||||||
|
|
||||||
|
assert.dom().hasText('template block text');
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,26 @@
|
||||||
|
import { module, test } from 'qunit';
|
||||||
|
import { setupRenderingTest } from 'frontend-reactive/tests/helpers';
|
||||||
|
import { render } from '@ember/test-helpers';
|
||||||
|
import { hbs } from 'ember-cli-htmlbars';
|
||||||
|
|
||||||
|
module('Integration | Component | account/overview', function (hooks) {
|
||||||
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
|
test('it renders', async function (assert) {
|
||||||
|
// Set any properties with this.set('myProperty', 'value');
|
||||||
|
// Handle any actions with this.set('myAction', function(val) { ... });
|
||||||
|
|
||||||
|
await render(hbs`<Account::Overview />`);
|
||||||
|
|
||||||
|
assert.dom().hasText('');
|
||||||
|
|
||||||
|
// Template block usage:
|
||||||
|
await render(hbs`
|
||||||
|
<Account::Overview>
|
||||||
|
template block text
|
||||||
|
</Account::Overview>
|
||||||
|
`);
|
||||||
|
|
||||||
|
assert.dom().hasText('template block text');
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in a new issue