[pve-devel] [PATCH manager 06/17] add new DiskStorageSelector.js
Emmanuel Kasper
e.kasper at proxmox.com
Tue Aug 29 17:53:35 CEST 2017
some coments inline
> +++ b/www/manager6/form/DiskStorageSelector.js
> @@ -0,0 +1,109 @@
> +Ext.define('PVE.form.DiskStorageSelector', {
> + extend: 'Ext.container.Container',
> + alias: 'widget.pveDiskStorageSelector',
> +
> + layout: 'fit',
> + defaults: {
> + margin: '0 0 5 0'
> + },
since the component has some new properties which we can set via
a config object, it would make to list these properties at the top, so
we know what they are like
hideSize: undefined, //
hideSelection: true // (maybe called hideRawDevSelector ?)
what do you think ? (idea taken from HDEdit.js)
> + changeStorage: function(f, value) {
> + var me = this;
> + var formatsel = me.getComponent('diskformat');
> + var hdfilesel = me.getComponent('hdimage');
> + var hdsizesel = me.getComponent('disksize');
> +
> + // initial store load, and reset/deletion of the storage
> + if (!value) {
> + hdfilesel.setDisabled(true);
> + hdfilesel.setVisible(false);
> +
> + formatsel.setDisabled(true);
> + return;
> + }
> +
> + var rec = f.store.getById(value);
> + // if the storage is not defined, or valid,
> + // we cannot know what to enable/disable
> + if (!rec) {
> + return;
> + }
> +
> + var format = PVE.Utils.getStorageFormat(rec.data.type);
> +
> + formatsel.setDisabled(format.formats.length === 1);
> + formatsel.setValue(format.formats.length === 1 ? 'raw' : 'qcow2');
> +
> + hdfilesel.setDisabled(!format.select || me.hideSelection);
> + hdfilesel.setVisible(format.select && !me.hideSelection);
> + if (!me.hideSelection) {
> + hdfilesel.setStorage(value);
> + }
> +
> + hdsizesel.setDisabled(format.select || me.hideSize);
> + hdsizesel.setVisible(!format.select && !me.hideSize);
> + },
> +
> + initComponent: function() {
> + var me = this;
> +
> + me.items = [
> + {
> + xtype: 'pveStorageSelector',
> + itemId: 'hdstorage',
> + name: 'hdstorage',
> + reference: 'hdstorage',
AFAIK if we access the components via getComponent() we just need the
itemID so we don't need a reference property on each item
More information about the pve-devel
mailing list