Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
parent
2c69c276e3
commit
49b329d45c
|
@ -168,7 +168,16 @@
|
|||
v-model="model.PhotoAltitude"
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs12 sm6 md3 class="pa-2">
|
||||
<v-text-field
|
||||
disabled
|
||||
hide-details
|
||||
label="Views"
|
||||
placeholder=""
|
||||
color="secondary-dark"
|
||||
v-model="model.PhotoViews"
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
<v-flex xs12 sm6 md3 class="pa-2">
|
||||
<v-text-field
|
||||
hide-details
|
||||
|
@ -207,17 +216,6 @@
|
|||
v-model="model.PhotoExposure"
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
<v-flex xs12 sm6 md3 class="pa-2">
|
||||
<v-text-field
|
||||
disabled
|
||||
hide-details
|
||||
label="Views"
|
||||
placeholder=""
|
||||
color="secondary-dark"
|
||||
v-model="model.PhotoViews"
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
|
||||
|
||||
<v-flex xs12 sm6 md3 class="pa-2">
|
||||
<v-text-field
|
||||
|
@ -285,11 +283,8 @@
|
|||
></v-textarea>
|
||||
</v-flex>
|
||||
<v-flex xs12 text-xs-right class="pt-3">
|
||||
<span class="subheading pb-3">
|
||||
Note: This is a first draft and may contain bugs
|
||||
</span>
|
||||
<v-btn @click.stop="cancel" depressed color="secondary-light" class="p-photo-dialog-cancel">
|
||||
<translate>Cancel</translate>
|
||||
<translate>Close</translate>
|
||||
</v-btn>
|
||||
<v-btn color="secondary-dark" depressed dark @click.stop="save"
|
||||
class="p-photo-dialog-confirm">
|
||||
|
@ -353,12 +348,14 @@
|
|||
if(!this.date) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return DateTime.fromISO(this.date).toLocaleString(DateTime.DATE_FULL);
|
||||
},
|
||||
timeFormatted() {
|
||||
if(!this.time) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return DateTime.fromISO(this.time).toLocaleString(DateTime.TIME_24_WITH_SECONDS);
|
||||
},
|
||||
countryOptions() {
|
||||
|
@ -387,12 +384,16 @@
|
|||
model.refreshFileAttr();
|
||||
|
||||
if(model.TakenAt) {
|
||||
this.date = DateTime.fromISO(model.TakenAt).toISODate();
|
||||
|
||||
this.time = DateTime.fromISO(model.TakenAt).toFormat("HH:mm:ss");
|
||||
const date = DateTime.fromISO(model.TakenAt).toUTC();
|
||||
this.date = date.toISODate();
|
||||
this.time = date.toFormat("HH:mm:ss");
|
||||
}
|
||||
},
|
||||
save() {
|
||||
if(this.time && this.date) {
|
||||
this.model.TakenAt = this.date + "T" + this.time + "Z";
|
||||
}
|
||||
|
||||
this.model.update();
|
||||
},
|
||||
cancel() {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div class="p-tab p-tab-photo-edit-todo">
|
||||
<v-container fluid>
|
||||
<p class="subheading pb-3">
|
||||
This is a first draft for an edit dialog. Feedback and contributions welcome.
|
||||
This is work in progress. Feedback and contributions welcome.
|
||||
</p>
|
||||
</v-container>
|
||||
</div>
|
||||
|
|
|
@ -13,10 +13,10 @@ class Abstract {
|
|||
}
|
||||
|
||||
setValues(values) {
|
||||
if(!values) return;
|
||||
if (!values) return;
|
||||
|
||||
for(let key in values) {
|
||||
if(values.hasOwnProperty(key) && key !== "__originalValues") {
|
||||
for (let key in values) {
|
||||
if (values.hasOwnProperty(key) && key !== "__originalValues") {
|
||||
this[key] = values[key];
|
||||
this.__originalValues[key] = values[key];
|
||||
}
|
||||
|
@ -25,12 +25,32 @@ class Abstract {
|
|||
return this;
|
||||
}
|
||||
|
||||
getValues() {
|
||||
getValues(changed) {
|
||||
const result = {};
|
||||
const defaults = this.getDefaults();
|
||||
|
||||
for(let key in this.__originalValues) {
|
||||
if(this.__originalValues.hasOwnProperty(key) && key !== "__originalValues") {
|
||||
result[key] = this[key];
|
||||
for (let key in this.__originalValues) {
|
||||
if (this.__originalValues.hasOwnProperty(key) && key !== "__originalValues") {
|
||||
let val;
|
||||
if (defaults.hasOwnProperty(key)) {
|
||||
switch (typeof defaults[key]) {
|
||||
case "bigint":
|
||||
case "number":
|
||||
val = parseFloat(this[key]);
|
||||
break;
|
||||
case "boolean":
|
||||
val = !!this[key];
|
||||
break;
|
||||
default:
|
||||
val = this[key];
|
||||
}
|
||||
} else {
|
||||
val = this[key];
|
||||
}
|
||||
|
||||
if(!changed || val !== this.__originalValues[key]) {
|
||||
result[key] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,7 +82,7 @@ class Abstract {
|
|||
}
|
||||
|
||||
update() {
|
||||
return Api.put(this.getEntityResource(), this.getValues()).then((response) => Promise.resolve(this.setValues(response.data)));
|
||||
return Api.put(this.getEntityResource(), this.getValues(true)).then((response) => Promise.resolve(this.setValues(response.data)));
|
||||
}
|
||||
|
||||
remove() {
|
||||
|
@ -113,7 +133,7 @@ class Abstract {
|
|||
return Api.get(this.getCollectionResource(), options).then((response) => {
|
||||
response.models = [];
|
||||
|
||||
for(let i = 0; i < response.data.length; i++) {
|
||||
for (let i = 0; i < response.data.length; i++) {
|
||||
response.models.push(new this(response.data[i]));
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class Photo extends Abstract {
|
|||
PhotoAltitude: 0,
|
||||
PhotoFocalLength: 0,
|
||||
PhotoIso: 0,
|
||||
PhotoFNumber: 0,
|
||||
PhotoFNumber: 0.0,
|
||||
PhotoExposure: "",
|
||||
PhotoViews: 0,
|
||||
Camera: {},
|
||||
|
|
|
@ -12,49 +12,49 @@ import (
|
|||
// A photo can have multiple images and sidecar files
|
||||
type Photo struct {
|
||||
ID uint `gorm:"primary_key"`
|
||||
TakenAt time.Time `gorm:"type:datetime;index:idx_photos_taken_uuid;"`
|
||||
TakenAt time.Time `gorm:"type:datetime;index:idx_photos_taken_uuid;" json:"TakenAt"`
|
||||
PhotoUUID string `gorm:"type:varbinary(36);unique_index;index:idx_photos_taken_uuid;"`
|
||||
PhotoPath string `gorm:"type:varbinary(512);index;"`
|
||||
PhotoName string `gorm:"type:varbinary(256);"`
|
||||
PhotoTitle string `json:"PhotoTitle"`
|
||||
PhotoTitleChanged bool
|
||||
PhotoDescription string `gorm:"type:text;"`
|
||||
PhotoNotes string `gorm:"type:text;"`
|
||||
PhotoArtist string `json:"PhotoArtist"`
|
||||
PhotoCopyright string `json:"PhotoCopyright"`
|
||||
PhotoFavorite bool `json:"PhotoFavorite"`
|
||||
PhotoPrivate bool `json:"PhotoPrivate"`
|
||||
PhotoNSFW bool `json:"PhotoNSFW"`
|
||||
PhotoStory bool `json:"PhotoStory"`
|
||||
PhotoLat float64 `gorm:"index;"`
|
||||
PhotoLng float64 `gorm:"index;"`
|
||||
PhotoAltitude int
|
||||
PhotoFocalLength int
|
||||
PhotoIso int
|
||||
PhotoFNumber float64
|
||||
PhotoExposure string `gorm:"type:varbinary(64);"`
|
||||
PhotoViews uint
|
||||
Camera *Camera
|
||||
CameraID uint `gorm:"index:idx_photos_camera_lens;"`
|
||||
Lens *Lens
|
||||
LensID uint `gorm:"index:idx_photos_camera_lens;"`
|
||||
CountryChanged bool
|
||||
Location *Location
|
||||
LocationID string `gorm:"type:varbinary(16);index;"`
|
||||
Place *Place
|
||||
PlaceID string `gorm:"type:varbinary(16);index;"`
|
||||
LocationChanged bool
|
||||
LocationEstimated bool
|
||||
PhotoCountry string `gorm:"index:idx_photos_country_year_month;"`
|
||||
PhotoTitleChanged bool `json:"PhotoTitleChanged"`
|
||||
PhotoDescription string `gorm:"type:text;" json:"PhotoDescription"`
|
||||
PhotoNotes string `gorm:"type:text;" json:"PhotoNotes"`
|
||||
PhotoArtist string `json:"PhotoArtist"`
|
||||
PhotoCopyright string `json:"PhotoCopyright"`
|
||||
PhotoFavorite bool `json:"PhotoFavorite"`
|
||||
PhotoPrivate bool `json:"PhotoPrivate"`
|
||||
PhotoNSFW bool `json:"PhotoNSFW"`
|
||||
PhotoStory bool `json:"PhotoStory"`
|
||||
PhotoLat float64 `gorm:"index;" json:"PhotoLat"`
|
||||
PhotoLng float64 `gorm:"index;" json:"PhotoLng"`
|
||||
PhotoAltitude int `json:"PhotoAltitude"`
|
||||
PhotoFocalLength int `json:"PhotoFocalLength"`
|
||||
PhotoIso int `json:"PhotoIso"`
|
||||
PhotoFNumber float64 `json:"PhotoFNumber"`
|
||||
PhotoExposure string `gorm:"type:varbinary(64);" json:"PhotoExposure"`
|
||||
CameraID uint `gorm:"index:idx_photos_camera_lens;" json:"CameraID"`
|
||||
LensID uint `gorm:"index:idx_photos_camera_lens;" json:"LensID"`
|
||||
LocationID string `gorm:"type:varbinary(16);index;" json:"LocationID"`
|
||||
PlaceID string `gorm:"type:varbinary(16);index;" json:"PlaceID"`
|
||||
LocationChanged bool `json:"LocationChanged"`
|
||||
LocationEstimated bool `json:"LocationEstimated"`
|
||||
PhotoCountry string `gorm:"index:idx_photos_country_year_month;" json:"PhotoCountry"`
|
||||
PhotoYear int `gorm:"index:idx_photos_country_year_month;"`
|
||||
PhotoMonth int `gorm:"index:idx_photos_country_year_month;"`
|
||||
TimeZone string `gorm:"type:varbinary(64);" json:"TimeZone"`
|
||||
TakenAtLocal time.Time `gorm:"type:datetime;"`
|
||||
TakenAtChanged bool
|
||||
TimeZone string `gorm:"type:varbinary(64);"`
|
||||
PhotoViews uint
|
||||
CountryChanged bool
|
||||
Camera *Camera `json:"-"`
|
||||
Lens *Lens `json:"-"`
|
||||
Location *Location `json:"-"`
|
||||
Place *Place `json:"-"`
|
||||
Files []File
|
||||
Labels []Label
|
||||
Keywords []Keyword
|
||||
Albums []Album
|
||||
Keywords []Keyword `json:"-"`
|
||||
Albums []Album `json:"-"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DeletedAt *time.Time `sql:"index"`
|
||||
|
|
Loading…
Reference in a new issue