aboutsummaryrefslogtreecommitdiff
path: root/src/components/settings_modal/helpers/attachment_setting.vue
blob: 96c80ab17ded0f76236ee4de319b2bf3787a96cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<template>
  <span
    v-if="matchesExpertLevel"
    class="AttachmentSetting"
    :class="{ '-compact': compact }"
  >
    <label
      :for="path"
      :class="{ 'faint': shouldBeDisabled }"
    >
      <template v-if="backendDescriptionLabel">
        {{ backendDescriptionLabel + ' ' }}
      </template>
      <template v-else-if="source === 'admin'">
        MISSING LABEL FOR {{ path }}
      </template>
      <slot v-else />

    </label>
    <p
      v-if="backendDescriptionDescription"
      class="setting-description"
      :class="{ 'faint': shouldBeDisabled }"
    >
      {{ backendDescriptionDescription + ' ' }}
    </p>
    <div class="attachment-input">
      <div class="controls control-field">
        <label for="path">{{ $t('settings.url') }}</label>
        <input
          :id="path"
          class="input string-input"
          :disabled="shouldBeDisabled"
          :value="realDraftMode ? draft : state"
          @change="update"
        >
        {{ ' ' }}
        <ModifiedIndicator
          :changed="isChanged"
          :onclick="reset"
        />
        <ProfileSettingIndicator :is-profile="isProfileSetting" />
      </div>
      <div v-if="!compact">{{ $t('settings.preview') }}</div>
      <Attachment
        class="attachment"
        :compact="compact"
        :attachment="attachment"
        size="small"
        hide-description
        @setMedia="onMedia"
        @naturalSizeLoad="onNaturalSizeLoad"
      />
      <div class="controls control-upload">
        <MediaUpload
          ref="mediaUpload"
          class="media-upload-icon"
          :drop-files="dropFiles"
          normal-button
          :accept-types="acceptTypes"
          @uploaded="setMediaFile"
          @upload-failed="uploadFailed"
        />
      </div>
    </div>
    <DraftButtons />
  </span>
</template>

<script src="./attachment_setting.js"></script>

<style lang="scss">
.AttachmentSetting {
  .attachment {
    display: block;
    width: 100%;
    height: 15em;
    margin-bottom: 0.5em;
  }

  .attachment-input {
    margin-left: 1em;
    display: flex;
    flex-direction: column;
    width: 20em;
  }

  &.-compact {
    .attachment-input {
      flex-direction: row;
      align-items: flex-end;
    }

    .attachment {
      flex: 0;
      order: 0;
      display: block;
      min-width: 4em;
      height: 4em;
      align-self: center;
      margin-bottom: 0;
    }

    .control-field {
      order: 1;
      min-width: 12em;
      margin-left: 0.5em;
    }

    .control-upload {
      order: 2;
      min-width: 12em;
      padding: 0 0.5em;
    }
  }

  .controls {
    margin-bottom: 0.5em;

    input,
    button {
      width: 100%;
    }
  }
}
</style>