mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-16 18:31:26 +01:00
Get widget extra documentation working
This allows <Class>.md beside <Class>.ts where we can add additional documentation such as examples
This commit is contained in:
parent
3b48d81651
commit
52b48140fe
@ -31,7 +31,7 @@ const l10n = [
|
|||||||
'mn', 'ms', 'my', 'nl', 'no', 'pa', 'pl', 'pt', 'ro', 'ru', 'si', 'sk', 'sl', 'sq', 'sr-cyr', 'sr', 'sv', 'th', 'tr',
|
'mn', 'ms', 'my', 'nl', 'no', 'pa', 'pl', 'pt', 'ro', 'ru', 'si', 'sk', 'sl', 'sq', 'sr-cyr', 'sr', 'sv', 'th', 'tr',
|
||||||
'uk', 'uz', 'uz_latn', 'vn', 'zh-tw', 'zh',
|
'uk', 'uz', 'uz_latn', 'vn', 'zh-tw', 'zh',
|
||||||
];
|
];
|
||||||
const lang = egw ? <string>egw.preference('lang') || "" : "";
|
const lang = egw && egw.preference ? <string>egw.preference('lang') || "" : "";
|
||||||
// only load localization, if we have one
|
// only load localization, if we have one
|
||||||
if (l10n.indexOf(lang) >= 0)
|
if (l10n.indexOf(lang) >= 0)
|
||||||
{
|
{
|
||||||
|
@ -231,12 +231,12 @@ export class Et2DateRange extends Et2InputWidget(FormControlMixin(LitElement))
|
|||||||
// or Date objects
|
// or Date objects
|
||||||
{
|
{
|
||||||
value: 'Today',
|
value: 'Today',
|
||||||
label: egw.lang('Today'),
|
label: egw.lang ? egw.lang('Today') : 'Today',
|
||||||
from(date) {return date;},
|
from(date) {return date;},
|
||||||
to(date) {return date;}
|
to(date) {return date;}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: egw.lang('Yesterday'),
|
label: egw.lang ? egw.lang("Yesterday") : "Yesterday",
|
||||||
value: 'Yesterday',
|
value: 'Yesterday',
|
||||||
from(date) {
|
from(date) {
|
||||||
date.setUTCDate(date.getUTCDate() - 1);
|
date.setUTCDate(date.getUTCDate() - 1);
|
||||||
@ -245,7 +245,7 @@ export class Et2DateRange extends Et2InputWidget(FormControlMixin(LitElement))
|
|||||||
to: ''
|
to: ''
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: egw.lang('This week'),
|
label: egw.lang ? egw.lang("This week") : "This week",
|
||||||
value: 'This week',
|
value: 'This week',
|
||||||
from(date) {return egw.week_start(date);},
|
from(date) {return egw.week_start(date);},
|
||||||
to(date) {
|
to(date) {
|
||||||
@ -254,7 +254,7 @@ export class Et2DateRange extends Et2InputWidget(FormControlMixin(LitElement))
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: egw.lang('Last week'),
|
label: egw.lang ? egw.lang("Last week") : "Last week",
|
||||||
value: 'Last week',
|
value: 'Last week',
|
||||||
from(date) {
|
from(date) {
|
||||||
var d = egw.week_start(date);
|
var d = egw.week_start(date);
|
||||||
@ -267,7 +267,7 @@ export class Et2DateRange extends Et2InputWidget(FormControlMixin(LitElement))
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: egw.lang('This month'),
|
label: egw.lang ? egw.lang("This month") : "This month",
|
||||||
value: 'This month',
|
value: 'This month',
|
||||||
from(date)
|
from(date)
|
||||||
{
|
{
|
||||||
@ -282,7 +282,7 @@ export class Et2DateRange extends Et2InputWidget(FormControlMixin(LitElement))
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: egw.lang('Last month'),
|
label: egw.lang ? egw.lang("Last month") : "Last month",
|
||||||
value: 'Last month',
|
value: 'Last month',
|
||||||
from(date)
|
from(date)
|
||||||
{
|
{
|
||||||
@ -298,7 +298,7 @@ export class Et2DateRange extends Et2InputWidget(FormControlMixin(LitElement))
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: egw.lang('Last 3 months'),
|
label: egw.lang ? egw.lang("Last 3 months") : "Last 3 months",
|
||||||
value: 'Last 3 months',
|
value: 'Last 3 months',
|
||||||
from(date)
|
from(date)
|
||||||
{
|
{
|
||||||
@ -314,7 +314,7 @@ export class Et2DateRange extends Et2InputWidget(FormControlMixin(LitElement))
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: egw.lang('This year'),
|
label: egw.lang ? egw.lang("This year") : "This year",
|
||||||
value: 'This year',
|
value: 'This year',
|
||||||
from(d) {
|
from(d) {
|
||||||
d.setUTCMonth(0);
|
d.setUTCMonth(0);
|
||||||
@ -328,7 +328,7 @@ export class Et2DateRange extends Et2InputWidget(FormControlMixin(LitElement))
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: egw.lang('Last year'),
|
label: egw.lang ? egw.lang("Last year") : "Last year",
|
||||||
value: 'Last year',
|
value: 'Last year',
|
||||||
from(d) {
|
from(d) {
|
||||||
d.setUTCMonth(0);
|
d.setUTCMonth(0);
|
||||||
|
14
api/js/etemplate/Et2Email/Et2Email.md
Normal file
14
api/js/etemplate/Et2Email/Et2Email.md
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
```html:preview
|
||||||
|
<et2-email></et2-email>
|
||||||
|
```
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
There are multiple components for dealing with email addresses.
|
||||||
|
* Email: This one
|
||||||
|
* [UrlEmail](../et2-url-email): One address, no suggestions. Used for contact information.
|
||||||
|
* [SelectEmail](../et2-select-email): Special case of Select for email addresses. Probably don't use it anymore.
|
||||||
|
|
||||||
|
:::
|
||||||
|
## Examples
|
@ -1179,7 +1179,6 @@ export class Et2Email extends Et2InputWidget(LitElement) implements SearchMixinI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore TypeScript is not recognizing that this widget is a LitElement
|
|
||||||
customElements.define("et2-email", Et2Email);
|
customElements.define("et2-email", Et2Email);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +18,10 @@ import {html} from "lit";
|
|||||||
* Customised Select widget for countries
|
* Customised Select widget for countries
|
||||||
* This widget uses CSS from api/templates/default/css/flags.css to set flags
|
* This widget uses CSS from api/templates/default/css/flags.css to set flags
|
||||||
*/
|
*/
|
||||||
egw(window).includeCSS("api/templates/default/css/flags.css")
|
if(egw && egw(window) && typeof egw(window).includeCSS == "function")
|
||||||
|
{
|
||||||
|
egw(window).includeCSS("api/templates/default/css/flags.css")
|
||||||
|
}
|
||||||
|
|
||||||
export class Et2SelectCountry extends Et2StaticSelectMixin(Et2Select)
|
export class Et2SelectCountry extends Et2StaticSelectMixin(Et2Select)
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ import {egw} from "../../jsapi/egw_global";
|
|||||||
|
|
||||||
// Minimum data to qualify as an image and not cause errors
|
// Minimum data to qualify as an image and not cause errors
|
||||||
const IMAGE_DEFAULT = {
|
const IMAGE_DEFAULT = {
|
||||||
title: egw.lang('loading'),
|
title: egw.lang ? egw.lang ? egw.lang('loading') : "'loading'" : "'loading'",
|
||||||
href: '',
|
href: '',
|
||||||
type: 'image/png',
|
type: 'image/png',
|
||||||
thumbnail: '',
|
thumbnail: '',
|
||||||
@ -680,7 +680,13 @@ export function ExposeMixin<B extends Constructor<LitElement>>(superclass : B)
|
|||||||
private _audio_player(_value)
|
private _audio_player(_value)
|
||||||
{
|
{
|
||||||
let button = [
|
let button = [
|
||||||
{"button_id": 1, "label": egw.lang('close'), id: '1', image: 'cancel', default: true}
|
{
|
||||||
|
"button_id": 1,
|
||||||
|
"label": egw.lang ? egw.lang("close") : "close",
|
||||||
|
id: '1',
|
||||||
|
image: 'cancel',
|
||||||
|
default: true
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
let mediaContent = this.getMedia(_value)[0];
|
let mediaContent = this.getMedia(_value)[0];
|
||||||
|
@ -282,7 +282,7 @@ window.app = {classes: {}};
|
|||||||
if (!gen_time_div.length) gen_time_div = jQuery('.pageGenTime');
|
if (!gen_time_div.length) gen_time_div = jQuery('.pageGenTime');
|
||||||
var gen_time_async = jQuery('.asyncIncludeTime').length > 0 ? jQuery('.asyncIncludeTime'):
|
var gen_time_async = jQuery('.asyncIncludeTime').length > 0 ? jQuery('.asyncIncludeTime'):
|
||||||
gen_time_div.append('<span class="asyncIncludeTime"></span>').find('.asyncIncludeTime');
|
gen_time_div.append('<span class="asyncIncludeTime"></span>').find('.asyncIncludeTime');
|
||||||
gen_time_async.text(egw.lang('async includes took %1s', (end_time-start_time)/1000));
|
gen_time_async.text(egw.lang ? egw.lang('async includes took %1s', (end_time - start_time) / 1000) : 'async includes took ' + (end_time - start_time) / 1000);
|
||||||
|
|
||||||
// Make sure opener knows when we close - start a heartbeat
|
// Make sure opener knows when we close - start a heartbeat
|
||||||
try {
|
try {
|
||||||
|
@ -48,7 +48,9 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
{# Markdown content #}
|
{# Markdown content #}
|
||||||
{{ content | safe }}
|
{% if component.content %}
|
||||||
|
{{ component.content | markdown | safe }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{# Slots #}
|
{# Slots #}
|
||||||
{% if component.slots.length %}
|
{% if component.slots.length %}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
const customElementsManifest = require('../../dist/custom-elements.json');
|
const customElementsManifest = require('../../dist/custom-elements.json');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
//
|
//
|
||||||
// Export it here so we can import it elsewhere and use the same version
|
// Export it here so we can import it elsewhere and use the same version
|
||||||
@ -74,6 +75,19 @@ module.exports.getAllComponents = function ()
|
|||||||
component.dependencies = dependencies.sort();
|
component.dependencies = dependencies.sort();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add custom docs - not monitored for file changes
|
||||||
|
allComponents.forEach(component =>
|
||||||
|
{
|
||||||
|
// Check for custom docs
|
||||||
|
const docPath = path.join('..', '..', path.dirname(component.path), component.name + ".md");
|
||||||
|
|
||||||
|
// Stick it in a variable so we can use the content filters
|
||||||
|
if (fs.existsSync(path.resolve(docPath)))
|
||||||
|
{
|
||||||
|
fs.readFile(docPath, (err, data) => component.content = data.toString());
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Sort by name
|
// Sort by name
|
||||||
return allComponents.sort((a, b) =>
|
return allComponents.sort((a, b) =>
|
||||||
{
|
{
|
||||||
|
@ -59,7 +59,7 @@ markdown.use(markdownItContainer, 'details', {
|
|||||||
markdownItReplaceIt.replacements.push({
|
markdownItReplaceIt.replacements.push({
|
||||||
name: 'github-issues',
|
name: 'github-issues',
|
||||||
re: /\[#([0-9]+)\]/gs,
|
re: /\[#([0-9]+)\]/gs,
|
||||||
sub: '<a href="https://github.com/shoelace-style/shoelace/issues/$1">#$1</a>',
|
sub: '<a href="https://github.com/egroupware/egroupware/issues/$1">#$1</a>',
|
||||||
html: true,
|
html: true,
|
||||||
default: true
|
default: true
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user