Getting work done. Registration form taking shape

Still needs styling and some more elements, but mostly usable now
This commit is contained in:
Melody Becker 2024-10-25 16:54:48 +02:00
parent f0638af99f
commit 467693d811
10 changed files with 38244 additions and 36547 deletions

View file

@ -1,10 +1,16 @@
<div class="registration-form"> <div class="registration-form">
<p class="registration-form-username">{{this.username}}</p> <h1 class="registration-form-username">username: {{this.args.username}}</h1>
<div class="registration-form-displayname">
<label> <label>
Displayname Displayname
<Input @type="text" @value={{this.displayname}} placeholder="Displayname" /> <Input
@type="text"
@value={{this.displayname}}
placeholder="Displayname"
/>
</label> </label>
</div>
<div class="registration-form-description">
<label> <label>
Description Description
<Input <Input
@ -13,6 +19,51 @@
placeholder="Account description" placeholder="Account description"
/> />
</label> </label>
<Util::StringArray @list={{this.gender}} /> </div>
<p>{{this.extracted}}</p> <div class="registration-form-mail">
<label>
Email
<Input @type="text" @value={{this.email}} placeholder="Email address" />
</label>
</div>
<div class="registration-form-gender">
<Util::StringArray
@list={{this.gender}}
@onNewElement={{this.genderAddedHandler}}
@onDeleteElement={{this.genderRemovedHandler}}
/>
</div>
<p>{{this.extracted}}</p>
<div class="register-form-being">
<Util::Multiselect @elements={{this.beingTypes}} />
</div>
<div class="register-form-default-post-mode">
<Util::OneOfArray
@elements={{array "Public" "Local" "Followers" "Direct"}}
@selected={{this.defaultpostmode}}
@name="default-post-mode"
@required={{true}}
/>
</div>
<div class="register-form-follow-approval">
<label>
Require approval for follow requests
<Input
@type="checkbox"
name="Follow approval"
@checked={{this.args.followapproval}}
/>
</label>
</div>
<div class="register-form-indexable">
<label>
Whether the account is indexable
<Input @type="checkbox" name="Indexable" @checked={{this.indexable}} />
</label>
</div>
<div class="register-form-custom-fields">
<Util::MapEdit @list={{this.customProperties}} />
</div>
{{! TODO: Custom fields (Two string arrays, lets go. Definitely won't be a pain to sync them up) }}
{{! TODO: Icon, Background, Banner }}
</div> </div>

View file

@ -1,21 +1,69 @@
import Component from '@glimmer/component' import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking' import { tracked } from '@glimmer/tracking';
export interface AuthRegistrationFormSignature { export interface AuthRegistrationFormSignature {
// 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 AuthRegistrationForm extends Component<AuthRegistrationFormSignature> { export default class AuthRegistrationForm extends Component<AuthRegistrationFormSignature> {
@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<{
name: string;
checked: boolean;
description: string;
}> = [
{
name: 'Human',
description: 'Human',
checked: true,
},
{
name: 'Cat',
description: 'Cat',
checked: false,
},
{
name: 'Fox',
description: 'Fox',
checked: false,
},
{
name: 'Dog',
description: 'Dog',
checked: false,
},
{
name: 'Robot',
description: 'Robot',
checked: false,
},
{
name: 'Doll',
description: 'Doll',
checked: false,
},
];
@tracked defaultpostmode: string = 'public';
@tracked followapproval: boolean = false;
// Actual custom properties stored in here
@tracked customProperties: Array<{ key: string; value: string }> = [];
@tracked indexable: boolean = true;
genderAddedHandler(newIndex: number) {
console.log('gender added');
}
genderRemovedHandler(removedIndex: number) {
console.log('gender removed');
}
} }

View file

@ -1,21 +1,21 @@
import { action } from '@ember/object' import { action } from '@ember/object';
import Component from '@glimmer/component' import Component from '@glimmer/component';
export interface UtilMultiselectSignature { export interface UtilMultiselectSignature {
// The arguments accepted by the component // The arguments accepted by the component
Args: { Args: {
elements: Array<{ name: string; checked: boolean; description: string }> elements: Array<{ name: string; checked: boolean; description: 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 UtilMultiselect extends Component<UtilMultiselectSignature> { export default class UtilMultiselect extends Component<UtilMultiselectSignature> {
@action onChange() { @action onChange() {
console.log(this.args.elements) console.log(this.args.elements);
} }
} }

View file

@ -10,8 +10,7 @@
<div <div
class="{{@remove-element-classes}}" class="{{@remove-element-classes}}"
type="button" type="button"
id="{{this.args.prefix}}-{{index}}" {{on "click" (fn this.removeElement index)}}
{{on "click" this.removeElement}}
> >
X X
</div> </div>

View file

@ -1,57 +1,56 @@
import MutableArray from '@ember/array/mutable' import MutableArray from '@ember/array/mutable';
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';
export interface UtilStringArraySignature { export interface UtilStringArraySignature {
// The arguments accepted by the component // The arguments accepted by the component
Args: { Args: {
list: MutableArray<{ value: string }> list: MutableArray<{ value: string }>;
prefix: string prefix: string;
} onNewElement: (index: number) => void;
onDeleteElement: (index: number) => void;
};
// 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 UtilStringArray extends Component<UtilStringArraySignature> { export default class UtilStringArray extends Component<UtilStringArraySignature> {
@action addElement() { @action addElement() {
MutableArray.apply(this.args.list) MutableArray.apply(this.args.list);
this.args.list.pushObject({ value: '' }) this.args.list.pushObject({ value: '' });
if (this.args.onNewElement)
this.args.onNewElement(this.args.list.length - 1);
} }
@action removeElement(event: MouseEvent) { @action removeElement(index: number) {
MutableArray.apply(this.args.list) MutableArray.apply(this.args.list);
const target = event.target as HTMLDivElement
const splits = target.id.split('-', 2)
if (splits.length != 2) return
const indexStr = splits[1]
//console.log('Content: ', indexStr)
if (!indexStr) return
//let index = this.args.list.find((elem) => elem == content) //let index = this.args.list.find((elem) => elem == content)
//let index = this.listCopy.findIndex((d) => d == content) //let index = this.listCopy.findIndex((d) => d == content)
this.args.list.removeAt(Number(indexStr)) this.args.list.removeAt(index);
if (this.args.onDeleteElement) this.args.onDeleteElement(index);
} }
transformArrayIntoUsable(arr: Array<string>): { [key: number]: string } { transformArrayIntoUsable(arr: Array<string>): { [key: number]: string } {
const out: { [key: number]: string } = {} const out: { [key: number]: string } = {};
const tmp = arr.map((elem: string, index: number) => { const tmp = arr.map((elem: string, index: number) => {
out[index] = elem out[index] = elem;
return elem return elem;
}) });
return out return out;
} }
countElemsInObj(obj: any): number { countElemsInObj(obj: any): number {
let count = 0 let count = 0;
for (var prop in obj) { for (const prop in obj) {
if (obj.hasOwnProperty(prop)) ++count if (obj.hasOwnProperty(prop)) ++count;
} }
return count return count;
} }
} }

View file

@ -1,9 +1,9 @@
import Route from '@ember/routing/route' import Route from '@ember/routing/route';
export default class RegisterFormRoute extends Route { export default class RegisterFormRoute extends Route {
async model() { async model() {
return { return {
list: [{ value: 'one' }, { value: 'two' }], list: [{ value: 'one' }, { value: 'two' }],
} };
} }
} }

View file

@ -140,4 +140,5 @@
:root { :root {
background-color: var(--background); background-color: var(--background);
color: var(--text);
} }

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -87,7 +87,9 @@
"ember-moment": "^10.0.1", "ember-moment": "^10.0.1",
"ember-page-title": "^8.2.3", "ember-page-title": "^8.2.3",
"ember-qunit": "^8.1.0", "ember-qunit": "^8.1.0",
"ember-radio-button": "^3.0.0-beta.1",
"ember-resolver": "^11.0.1", "ember-resolver": "^11.0.1",
"ember-select-light": "^2.0.5",
"ember-simple-auth": "^6.1.0", "ember-simple-auth": "^6.1.0",
"ember-source": "~5.11.0", "ember-source": "~5.11.0",
"ember-template-lint": "^5.13.0", "ember-template-lint": "^5.13.0",