WIP on caching static option file and searching it client-side

Get it working in nextmatch
This commit is contained in:
nathan 2023-07-24 15:12:45 -06:00
parent b013f75eef
commit edcc260b7b
4 changed files with 25 additions and 13 deletions

View File

@ -46,7 +46,8 @@ li {
return {
...super.properties,
value: String,
select_options: {type: Array}
select_options: {type: Array},
searchUrl: String // Used for options from file
}
}
@ -64,12 +65,16 @@ li {
public async getUpdateComplete()
{
const result = await super.getUpdateComplete();
if(this.__fetchComplete)
{
const response = await super.getUpdateComplete();
await this.__fetchComplete;
return response;
}
else
{
return super.getUpdateComplete();
}
return result;
}
protected find_select_options(_attrs)
@ -81,13 +86,14 @@ li {
}
// Cache options from file
if(_attrs.searchUrl && _attrs.searchUrl.includes(".json") && this.__fetchComplete == null)
if(this.searchUrl && this.searchUrl.includes(".json") && this.__fetchComplete == null)
{
this.__fetchComplete = StaticOptions.cached_from_file(this, _attrs.searchUrl).then(options =>
{
this.select_options = options;
this.requestUpdate();
});
this.__fetchComplete = StaticOptions.cached_from_file(this, this.searchUrl)
.then(options =>
{
this.select_options = options;
this.requestUpdate();
});
}
}

View File

@ -617,7 +617,7 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
if(field.values && field.values["@"])
{
// Options are in a list stored in a file
attrs.searchUrl = this.egw().webserverUrl + '/webdav.php' + field.values["@"];
attrs.searchUrl = field.values["@"];
}
return true;
}

View File

@ -4196,7 +4196,7 @@ export class et2_nextmatch_customfields extends et2_customfields_list implements
};
if(field.values["@"])
{
attrs.searchUrl = this.egw().webserverUrl + '/webdav.php' + field.values["@"];
attrs.searchUrl = field.values["@"];
}
widget = loadWebComponent(
field.type == 'select-account' ? 'et2-nextmatch-header-account' : "et2-nextmatch-header-filter",

View File

@ -245,9 +245,15 @@ class Customfields extends Transformer
if (!empty($data['values']))
{
// Full URL for options from file
if(!empty($data['values']['@']))
if(!empty($data['values']['@']) && strpos($data['values']['@'], '/') == 0 && !str_contains($data['values']['@'], 'webdav.php') &&
$stat = Api\Vfs::stat($data['values']['@'])
)
{
$fields[$data['name']]['values']['@'] = Api\Framework::link(Api\Vfs::download_url($data['values']['@']));
$data['values']['@'] = $fields[$data['name']]['values']['@'] = Api\Framework::link(
Api\Vfs::download_url($data['values']['@']),
['download' => $stat['mtime']]
);
}
Select::fix_encoded_options($data['values']);
}