/**
 * @license
 * Copyright 2020 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

foam.CLASS({
  package: 'foam.i18n',
  name: 'InlineLocaleEditor',
  extends: 'foam.u2.tag.Input',

  css: `
    ^ { border: 1px solid red; padding: 4px; }
  `,

  imports: [
    'localeDAO',
    'translationService'
  ],

  properties: [
    {
      name: 'source'
    },
    {
      name: 'defaultText'
    },
    {
      name: 'mode',
      value: foam.u2.DisplayMode.RW
    }
  ],

  methods: [
    function initE() {
      this.SUPER();
      this.addClass(this.myClass());
      this.data$.sub(this.onDataUpdate);
    }
  ],

  listeners: [
    function onDataUpdate() {
      console.log('**********', this.source);
    }
  ]
});

@@ -279,16 +279,53 @@
 %7D%0A  %60,%0A%0A
+  requires: %5B 'foam.i18n.Locale' %5D,%0A%0A
   import
@@ -774,17 +774,308 @@
 s.source
-)
+, this.defaultText, this.data);%0A      var l = this.Locale.create(%7B%0A        locale:  foam.lang,%0A        variant: foam.variant,%0A        source:  this.source,%0A        target:  this.data%0A      %7D);%0A%0A      this.localeDAO.put(l);%0A%0A      this.translationService.localeEntries%5Bthis.source%5D = this.data
 ;%0A    %7D%0A

Implement behaviour for InlineLocaleEditor.