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 { 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);
} }
} }

View file

@ -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"

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -3,7 +3,7 @@
/* Note: CSS is fucking stupid. It applies styles not in the order classes are set on an element, /* Note: CSS is fucking stupid. It applies styles not in the order classes are set on an element,
* but in the order they appear in the css files */ * but in the order they appear in the css files */
/*@import url("debug.css");*/ /* @import url("debug.css"); */
@import url("fonts.css"); @import url("fonts.css");
@import url("colors.css"); @import url("colors.css");
@import url("util.css"); @import url("util.css");

View file

@ -29,8 +29,10 @@
.registration-form-mail-input { .registration-form-mail-input {
width: max-content; width: max-content;
/*display: flex;*/
/*flex-grow: 1;*/ /* display: flex; */
/* flex-grow: 1; */
} }
.registration-form-description-wrapper { .registration-form-description-wrapper {

View file

@ -11,24 +11,26 @@
.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 {
/*margin: 0;*/ /* margin: 0; */
margin-top: 0.75em; margin-top: 0.75em;
margin-left: 0.4em; margin-left: 0.4em;
} }
.mail-ok { .mail-ok {
color: green; color: green;
/*margin-top: -0.25lh;*/
/*margin-bottom: -0.28lh;*/ /* margin-top: -0.25lh; */
/* margin-bottom: -0.28lh; */
font-size: 0.9lh; font-size: 0.9lh;
margin: 0; margin: 0;
margin-left: 0.2em; margin-left: 0.2em;

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