Skip to content

Commit

Permalink
Fixes bug with old folder ID update
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarssanchez committed Sep 5, 2022
1 parent 82b69f1 commit 552364b
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 44 deletions.
38 changes: 19 additions & 19 deletions assets/js/brightcove-admin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions assets/js/src/models/media-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ var MediaCollection = Backbone.Collection.extend({
this.searchTerm = options.searchTerm || '';
this.dates = options.dates || 'all';
this.tag = options.tag || '';
this.folderId = options.folderId || '';
this.oldFolderId = options.oldFolderId || '';
this.folder_id = options.folder_id || '';
this.old_folder_id = options.old_folder_id || '';
this.labelPath = options.labelPath || '';
this.oldLabelPath = options.oldLabelPath || '';

Expand Down Expand Up @@ -85,14 +85,14 @@ var MediaCollection = Backbone.Collection.extend({
this.fetch();
});

this.listenTo(wpbc.broadcast, 'change:folder', function (folderId) {
this.oldFolderId = this.folderId;
this.listenTo(wpbc.broadcast, 'change:folder', function (folder_id) {
this.old_folder_id = this.folder_id;

if (folderId === 'all') {
folderId = '';
if (folder_id === 'all') {
folder_id = '';
}

this.folderId = folderId;
this.folder_id = folder_id;
this.fetch();
});

Expand Down Expand Up @@ -189,8 +189,8 @@ var MediaCollection = Backbone.Collection.extend({
labels: this.labels,
labelPath: this.labelPath,
oldLabelPath: this.oldLabelPath,
oldFolderId: this.oldFolderId,
folderId: this.folderId,
old_folder_id: this.old_folder_id,
folder_id: this.folder_id,
state: this.state,
oldState: this.oldState,
tagName: wpbc.preload.tags[this.tag],
Expand All @@ -205,7 +205,7 @@ var MediaCollection = Backbone.Collection.extend({
'search',
'tags',
'type',
'folderId',
'folder_id',
'tagName',
'state',
);
Expand Down
4 changes: 2 additions & 2 deletions assets/js/src/models/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ var MediaModel = Backbone.Model.extend({
name: this.get('name'),
nonce: wpbc.preload.nonce,
tags: this.get('tags'),
oldFolderId: this.get('oldFolderId'),
folderId: this.get('folderId'),
old_folder_id: this.get('old_folder_id'),
folder_id: this.get('folder_id'),
type: this.get('mediaType'),
custom_fields: this.get('custom_fields'),
history: this.get('_change_history'),
Expand Down
4 changes: 2 additions & 2 deletions assets/js/src/views/brightcove-media-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ var BrightcoveMediaManagerView = BrightcoveView.extend({

this.listenTo(wpbc.broadcast, 'change:folder', function (folder) {
this.clearPreview();
this.model.set('oldFolderId', this.model.get('folderId'));
this.model.set('folderId', folder);
this.model.set('old_folder_id', this.model.get('folder_id'));
this.model.set('folder_id', folder);
});

this.listenTo(wpbc.broadcast, 'change:label', function (labelPath) {
Expand Down
6 changes: 3 additions & 3 deletions assets/js/src/views/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var ToolbarView = BrightcoveView.extend({
folders: wpbc.preload.folders,
labels: wpbc.preload.labels,
labelPath: this.model.get('labelPath'),
folderId: this.model.get('folderId'),
folder_id: this.model.get('folder_id'),
account: this.model.get('account'),
};

Expand Down Expand Up @@ -108,8 +108,8 @@ var ToolbarView = BrightcoveView.extend({
},

foldersChanged: function (event) {
this.model.set('oldFolderId', this.model.get('folderId'));
this.model.set('folderId', event.target.value);
this.model.set('old_folder_id', this.model.get('folder_id'));
this.model.set('folder_id', event.target.value);
wpbc.broadcast.trigger('change:folder', event.target.value);
},

Expand Down
4 changes: 2 additions & 2 deletions assets/js/src/views/video-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ var VideoEditView = BrightcoveView.extend({
this.model.set('width', this.$el.find('.brightcove-width').val());
this.model.set('poster', this.$el.find('.brightcove-poster').val());
this.model.set('thumbnail', this.$el.find('.brightcove-thumbnail').val());
this.model.set('folderId', this.$el.find('.brightcove-folder').val());
this.model.set('folder_id', this.$el.find('.brightcove-folder').val());

const isVariant = this.$el.find('.brightcove-variant').val();

Expand Down Expand Up @@ -585,7 +585,7 @@ var VideoEditView = BrightcoveView.extend({
// Due to a change in the API response, text_tracks might not be defined if the video lacks text_tracks.
options.text_tracks = options.text_tracks || [];

this.model.set('oldFolderId', options.folder_id);
this.model.set('old_folder_id', options.folder_id);

// Render the model into the template
this.$el.html(this.template(options));
Expand Down
4 changes: 2 additions & 2 deletions includes/admin/api/class-bc-admin-media-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,9 @@ public function bc_ajax_update_video_or_playlist() {
} else {
$status = $this->videos->update_bc_video( $updated_data );

if ( isset( $_POST['folder_id'] ) && isset( $_POST['oldfolder_id'] ) ) {
if ( isset( $_POST['folder_id'] ) && isset( $_POST['old_folder_id'] ) ) {
$folder_id = sanitize_text_field( $_POST['folder_id'] );
$old_folder_id = sanitize_text_field( $_POST['oldfolder_id'] );
$old_folder_id = sanitize_text_field( $_POST['old_folder_id'] );

$this->cms_api->add_folder_to_video( $old_folder_id, $folder_id, $updated_data['video_id'] );
}
Expand Down
8 changes: 4 additions & 4 deletions includes/admin/class-bc-templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ class="brightcove-datetime brightcove-end-date"
<span class="name"><?php esc_html_e( 'Folder', 'brightcove' ); ?></span>
<select class="brightcove-folder">
<option value="">None</option>
<# _.each(data.folders, function (folderName, folderId) { #>
<option value="{{ folderId }}" <# if ( data.folder_id === folderId ) { #>selected<# } #>>
<# _.each(data.folders, function (folderName, folder_id) { #>
<option value="{{ folder_id }}" <# if ( data.folder_id === folder_id ) { #>selected<# } #>>
{{ folderName }}
</option>
<# }); #>
Expand Down Expand Up @@ -1245,8 +1245,8 @@ class="brightcove-datetime brightcove-end-date"
<label for="media-attachment-folders-filters" class="screen-reader-text"><?php esc_html_e( 'Filter by folder', 'brightcove' ); ?></label>
<select id="media-attachment-folders-filters" class="brightcove-media-folders attachment-filters">
<option value="all"><?php esc_html_e( 'All folders', 'brightcove' ); ?></option>
<# _.each(data.folders, function (folderName, folderId) { #>
<option value="{{ folderId }}" <# if ( data.folderId === folderId ) { #>selected<# } #>>
<# _.each(data.folders, function (folderName, folder_id) { #>
<option value="{{ folder_id }}" <# if ( data.folder_id === folder_id ) { #>selected<# } #>>
{{ folderName }}
</option>
<# }); #>
Expand Down

0 comments on commit 552364b

Please sign in to comment.