Add read-only mode to map and array editors

This commit is contained in:
Melody Becker 2024-11-19 15:05:12 +01:00
parent 8a4c19dd17
commit 46bfac7540
13 changed files with 174 additions and 79 deletions

View file

@ -0,0 +1 @@
{{yield}}

View file

@ -0,0 +1 @@
{{yield}}

View file

@ -1,29 +1,29 @@
import { action } from '@ember/object'
import Component from '@glimmer/component'
import { tracked } from '@glimmer/tracking'
import isValidMail from 'frontend-reactive/helpers/is-valid-mail'
import { action } from '@ember/object';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import isValidMail from 'frontend-reactive/helpers/is-valid-mail';
export interface AuthPostRegistrationFormSignature {
// The arguments accepted by the component
Args: {
username: string
}
username: string;
};
// Any blocks yielded by the component
Blocks: {
default: []
}
default: [];
};
// The element to which `...attributes` is applied in the component template
Element: null
Element: null;
}
export default class AuthPostRegistrationForm extends Component<AuthPostRegistrationFormSignature> {
@tracked displayname: string = this.args.username
@tracked description: string = ''
@tracked gender: Array<{ value: string }> = []
@tracked displayname: string = this.args.username;
@tracked description: string = '';
@tracked gender: Array<{ value: string }> = [];
@tracked beingTypes: Array<{
name: string
checked: boolean
description: string
name: string;
checked: boolean;
description: string;
}> = [
{
name: 'Human',
@ -55,22 +55,22 @@ export default class AuthPostRegistrationForm extends Component<AuthPostRegistra
description: 'Doll',
checked: false,
},
]
@tracked defaultpostmode: string = 'Public'
@tracked followapproval: boolean = false
@tracked customProperties: Array<{ key: string; value: string }> = []
@tracked indexable: boolean = true
@tracked mail = { mail: '', valid: false }
@tracked enableBlueskyIntegration = false
];
@tracked defaultpostmode: string = 'Public';
@tracked followapproval: boolean = false;
@tracked customProperties: Array<{ key: string; value: string }> = [];
@tracked indexable: boolean = true;
@tracked mail = { mail: '', valid: false };
@tracked enableBlueskyIntegration = false;
genderAddedHandler(newIndex: number) {
console.log('gender added')
console.log('gender added');
}
genderRemovedHandler(removedIndex: number) {
console.log('gender removed')
console.log('gender removed');
}
@action test() {
console.log(this.mail)
console.log(this.mail);
}
}

View file

@ -1,7 +1,7 @@
<div class="mail-entry {{@wrapper-classes}}">
<label>
Email
<!--<div class="filling-spacer"/>-->
{{!--<div class="filling-spacer"/>--}}
<Input
class="mail-input {{if this.mailOk "mail-input-ok" "mail-input-error"}} {{@input-classes}}"
@type="text"

View file

@ -1,4 +1,16 @@
<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>
{{#each this.args.list as |element index|}}
<li>
@ -24,4 +36,5 @@
>
Add element
</div>
{{/if}}
</div>

View file

@ -1,4 +1,15 @@
<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|}}
<label class={{@label-class}}>
{{element.description}}
@ -11,4 +22,5 @@
/>
</label>
{{/each}}
{{/if}}
</div>

View file

@ -1,4 +1,7 @@
<div class="{{@wrapper-class}}">
{{#if @readonly}}
<p class="{{@element-classes}}">{{@selected}}</p>
{{else}}
{{#each @elements as |element index|}}
<RadioButton
@value="{{element}}"
@ -9,4 +12,5 @@
{{element}}
</RadioButton>
{{/each}}
{{/if}}
</div>

View file

@ -1,4 +1,11 @@
<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>
{{#each this.args.list as |element index|}}
<li>
@ -27,4 +34,5 @@
>
Add element
</div>
{{/if}}
</div>

View file

@ -29,7 +29,9 @@
.registration-form-mail-input {
width: max-content;
/* display: flex; */
/* flex-grow: 1; */
}

View file

@ -11,12 +11,12 @@
.mail-input-ok {
border: 1px solid green;
box-shadow: 0px 0px 5px green;
box-shadow: 0 0 5px green;
}
.mail-input-error {
border: 1px solid red;
box-shadow: 0px 0px 5px red;
box-shadow: 0 0 5px red;
}
.mail-status {
@ -27,7 +27,9 @@
.mail-ok {
color: green;
/* margin-top: -0.25lh; */
/* margin-bottom: -0.28lh; */
font-size: 0.9lh;
margin: 0;

View file

@ -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');
});
});

View file

@ -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');
});
});