make countdown a value-widget to get automatic timezone handling by date widgets beforeSendToClient method

This commit is contained in:
Ralf Becker 2021-01-28 12:07:52 +02:00
parent d0d7031417
commit 69b33e9288
3 changed files with 12 additions and 19 deletions

View File

@ -22,6 +22,7 @@ var __extends = (this && this.__extends) || (function () {
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.et2_countdown = void 0;
/*egw:uses
/vendor/bower-asset/jquery/dist/jquery.js;
et2_core_baseWidget;
@ -29,9 +30,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
require("./et2_core_common");
var et2_core_inheritance_1 = require("./et2_core_inheritance");
var et2_core_widget_1 = require("./et2_core_widget");
var et2_core_baseWidget_1 = require("./et2_core_baseWidget");
var et2_core_valueWidget_1 = require("./et2_core_valueWidget");
/**
* Class which implements the "countdown" XET-Tag
*
* Value for countdown is the expiry date of the counter.
*/
var et2_countdown = /** @class */ (function (_super) {
__extends(et2_countdown, _super);
@ -64,7 +67,7 @@ var et2_countdown = /** @class */ (function (_super) {
_this.setDOMNode(_this.container[0]);
return _this;
}
et2_countdown.prototype.set_time = function (_time) {
et2_countdown.prototype.set_value = function (_time) {
if (_time == "")
return;
this.time.set_value(_time);
@ -116,12 +119,6 @@ var et2_countdown = /** @class */ (function (_super) {
return this.options.format == 's' ? egw.lang(_v).substr(0, 1) : egw.lang(_v);
};
et2_countdown._attributes = {
time: {
name: "time",
type: "any",
default: "",
description: ""
},
format: {
name: "display format",
type: "string",
@ -154,7 +151,7 @@ var et2_countdown = /** @class */ (function (_super) {
}
};
return et2_countdown;
}(et2_core_baseWidget_1.et2_baseWidget));
}(et2_core_valueWidget_1.et2_valueWidget));
exports.et2_countdown = et2_countdown;
et2_core_widget_1.et2_register_widget(et2_countdown, ["countdown"]);
//# sourceMappingURL=et2_widget_countdown.js.map

View File

@ -18,18 +18,15 @@ import {ClassWithAttributes} from "./et2_core_inheritance";
import {et2_createWidget, et2_register_widget, WidgetConfig} from "./et2_core_widget";
import {et2_date} from "./et2_widget_date";
import {et2_baseWidget} from "./et2_core_baseWidget";
import {et2_valueWidget} from "./et2_core_valueWidget";
/**
* Class which implements the "countdown" XET-Tag
*
* Value for countdown is the expiry date of the counter.
*/
export class et2_countdown extends et2_baseWidget {
export class et2_countdown extends et2_valueWidget {
static readonly _attributes: any = {
time: {
name: "time",
type: "any",
default: "",
description: ""
},
format: {
name: "display format",
type: "string",
@ -95,7 +92,7 @@ export class et2_countdown extends et2_baseWidget {
this.setDOMNode(this.container[0]);
}
public set_time(_time)
public set_value(_time)
{
if (_time == "") return;
this.time.set_value(_time);
@ -107,7 +104,6 @@ export class et2_countdown extends et2_baseWidget {
if (typeof self.onFinish == "function") self.onFinish();
}
}, 1000);
}
private _updateTimer()

View File

@ -256,4 +256,4 @@ class Date extends Transformer
}
}
}
\EGroupware\Api\Etemplate\Widget::registerWidget(__NAMESPACE__.'\\Date', array('time_or_date'));
\EGroupware\Api\Etemplate\Widget::registerWidget(__NAMESPACE__.'\\Date', array('time_or_date', 'countdown'));