diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-02-04 11:06:27 +0100 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-02-04 11:07:11 +0100 |
commit | dd51a36931d4ba450fb4a8d7fe5c1609892d25b6 (patch) | |
tree | 5261739552340d953c4952e8c8f0fc873fee9696 | |
parent | 11e3a3bd87de2c3ddf757943e898e78a8df7d1a0 (diff) |
Add PRODID to new contacts
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
-rw-r--r-- | .eslintrc.js | 3 | ||||
-rw-r--r-- | lib/Controller/PageController.php | 29 | ||||
-rw-r--r-- | src/views/Contacts.vue | 2 |
3 files changed, 28 insertions, 6 deletions
diff --git a/.eslintrc.js b/.eslintrc.js index 6e1d2a98..d3378af3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,8 +7,9 @@ module.exports = { jest: true }, globals: { - t: true, + oca_contacts: true, n: true, + t: true, OC: true, OCA: true, Vue: true, diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index afbccb45..95951337 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -25,17 +25,27 @@ namespace OCA\Contacts\Controller; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\TemplateResponse; +use OCP\IConfig; use OCP\IRequest; class PageController extends Controller { + protected $appName; private $userId; + /** + * @var IConfig + */ + private $config; + public function __construct(string $AppName, IRequest $request, - string $UserId = null) { + string $UserId = null, + IConfig $config) { parent::__construct($AppName, $request); + $this->appName = $AppName; $this->userId = $UserId; + $this->config = $config; } /** @@ -45,9 +55,20 @@ class PageController extends Controller { * Default routing */ public function index(): TemplateResponse { - $params = ['user' => $this->userId]; - - return new TemplateResponse('contacts', 'main', $params); // templates/main.php + \OCP\Util::connectHook('\OCP\Config', 'js', $this, 'addJavaScriptVariablesForIndex'); + return new TemplateResponse('contacts', 'main'); // templates/main.php } + /** + * add parameters to javascript for user sites + * + * @param array $array + */ + public function addJavaScriptVariablesForIndex(array $array) { + $appversion = $this->config->getAppValue($this->appName, 'installed_version'); + + $array['array']['oca_contacts'] = \json_encode([ + 'versionstring' => $appversion, + ]); + } } diff --git a/src/views/Contacts.vue b/src/views/Contacts.vue index d9412555..19663370 100644 --- a/src/views/Contacts.vue +++ b/src/views/Contacts.vue @@ -265,7 +265,7 @@ export default { methods: { async newContact() { - let contact = new Contact('BEGIN:VCARD\nVERSION:4.0\nEND:VCARD', this.defaultAddressbook) + let contact = new Contact(`BEGIN:VCARD\nVERSION:4.0\nPRODID:-//Nextcloud Contacts v${oca_contacts.versionstring}\nEND:VCARD`, this.defaultAddressbook) const properties = rfcProps.properties(this) contact.fullName = t('contacts', 'New contact') // itterate over all properties (filter is not usable on objects and we need the key of the property) |