mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-03 16:10:31 +00:00
e050506a05
ExportService gets removed and instead a global class registry is added. The `init.js` file is split into `init_sync.js` and `init_async.js` so that synchronous code that isn't dependent on imports is guarenteed to run before initgui.js. The globalThis scope and service-script API now expose `def`, a function for registering class definitions, and `use`, a function for obtaining registered classes.
62 lines
1.9 KiB
JavaScript
62 lines
1.9 KiB
JavaScript
const Component = use('util.Component');
|
|
|
|
/**
|
|
* Display a list of checkboxes for the user to confirm.
|
|
*/
|
|
export default def(class ConfirmationsView extends Component {
|
|
static ID = 'ui.component.ConfirmationsView';
|
|
|
|
static PROPERTIES = {
|
|
confirmations: {
|
|
description: 'The list of confirmations to display',
|
|
},
|
|
confirmed: {
|
|
description: 'True iff all confirmations are checked',
|
|
},
|
|
}
|
|
|
|
static CSS = /*css*/`
|
|
.confirmations {
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
.looks-good {
|
|
margin-top: 20px;
|
|
color: hsl(220, 25%, 31%);
|
|
font-size: 20px;
|
|
font-weight: 700;
|
|
display: none;
|
|
}
|
|
`
|
|
|
|
create_template ({ template }) {
|
|
$(template).html(/*html*/`
|
|
<div class="confirmations">
|
|
${
|
|
this.get('confirmations').map((confirmation, index) => {
|
|
return /*html*/`
|
|
<div>
|
|
<input type="checkbox" id="confirmation-${index}" name="confirmation-${index}">
|
|
<label for="confirmation-${index}">${confirmation}</label>
|
|
</div>
|
|
`;
|
|
}).join('')
|
|
}
|
|
<span class="looks-good">${i18n('looks_good')}</span>
|
|
</div>
|
|
`);
|
|
}
|
|
|
|
on_ready ({ listen }) {
|
|
// update `confirmed` property when checkboxes are checked
|
|
$(this.dom_).find('input').on('change', () => {
|
|
this.set('confirmed', $(this.dom_).find('input').toArray().every(input => input.checked));
|
|
if ( this.get('confirmed') ) {
|
|
$(this.dom_).find('.looks-good').show();
|
|
} else {
|
|
$(this.dom_).find('.looks-good').hide();
|
|
}
|
|
});
|
|
}
|
|
});
|